Skip to content

Support nested body params in map objects. #2684

@veleek

Description

@veleek

Problem statement

Nested properties that generate map objects don't create error messages that describe the full path to that object. Instead the error message just refers to the property as though it's a top-level property.

Example CreateRequest JSON:

{
  "data": {
    "gameType": {
      "value": "Something longer than 2048chars...",
    },
  }
}

Example error:

value in body should be at most 2048 chars long.

This is related to #2595 which added support for paths for nested non-map properties of objects.

Swagger specification

  ...
  "components": {
    "schemas": {
      "DataObject": {
        "type": "object",
        "nullable": true,
        "properties": {
          "value": {
            "type": "string",
            "nullable": true,
            "maxLength": 2048,
          },
        },
        "additionalProperties": false
      },
      "CreateRequest": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/DataObject"
            },
            "nullable": true,
          }
        },
        ...
  }

Steps to reproduce

  1. Create a spec with a map param that returns CompositeError from its Validate method.
  2. Generate client code and verify the validation logic for nested properties returns errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions