Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message formatting for nested parameters #9774

Closed
glowcloud opened this issue Apr 3, 2024 · 1 comment
Closed

Error message formatting for nested parameters #9774

glowcloud opened this issue Apr 3, 2024 · 1 comment

Comments

@glowcloud
Copy link
Contributor

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Version: 123.0.6312.107
  • Swagger-UI version: 5.13.0
  • Swagger/OpenAPI version: Swagger 2.0, OpenAPI 3.x

Content & configuration

Example Swagger/OpenAPI definition:

{
  "openapi": "3.1.0",
  "info": {
    "title": "Server",
    "version": "0.0.1"
  },
  "paths": {
    "/endpoint": {
      "get": {
        "responses": {},
        "parameters": [
          {
            "name": "param",
            "in": "query",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "a": {
                        "type": "string"
                      },
                      "b": {
                        "type": "number"
                      }
                    }
                  }
                }
              }
            }
          },
          {
            "name": "secondParam",
            "in": "query",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "a": {
                      "type": "object",
                      "properties": {
                        "a": {
                          "type": "object",
                          "properties": {
                            "a": {
                              "type": "string"
                            },
                            "b": {
                              "type": "number"
                            }
                          }
                        },
                        "b": {
                          "type": "number"
                        }
                      }
                    },
                    "b": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        ]
      }
    }
  }
}

Describe the bug you're encountering

Errors for nested parameters aren't properly formatted and sometimes show undefined string.

Screenshot 2024-04-03 at 13 15 19 Screenshot 2024-04-03 at 13 15 23

Expected behavior

Errors should be formatted in a clear way, ex.
a.b.c: value must be a string or a[b][c]: value must be a string or a: b: c: value must be a string

They should also not contain the undefined string, instead it should be shown without trying to specify the affected value, ex:

Screenshot 2024-04-03 at 13 26 58

Additional context or thoughts

This is a follow up for #9687. The validationErrors function should be updated to take nested parameters/errors into account.

@glowcloud glowcloud self-assigned this Apr 3, 2024
@glowcloud glowcloud changed the title Error formatting for nested parameters Error message formatting for nested parameters Apr 3, 2024
@glowcloud
Copy link
Contributor Author

Addressed in 0f395c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant