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

ns-openapi-3-1: normalize-parameter-examples refractor plugin incorrectly sets schema example as an array of examples #4229

Closed
glowcloud opened this issue Jul 8, 2024 · 1 comment
Assignees
Labels
ApiDOM bug Something isn't working OpenAPI 3.1

Comments

@glowcloud
Copy link
Contributor

When normalizing a parameter such as

     "name": {
       "name": "name",
       "in": "query",
       "description": "name of the pet",
       "required": false,
       "schema": {
         "type": "string",
         "example": "schema example"
       },
       "examples": {
         "example1": {
           "value": "examples example"
         }
       }
     }

the example field in the schema will be normalized to:

"example": ['examples example']

Instead, it should be normalized to:

"example": "examples example"

This happens because we set example to the array of examples:

if (typeof parameterElement.schema.example !== 'undefined') {
parameterElement.schema.set('example', examples);
storage!.append(parameterJSONPointer);
}

instead, we should be setting it to the first example of the examples array like we do in the normalize-header-examples plugin:
if (typeof headerElement.schema.example !== 'undefined') {
headerElement.schema.set('example', examples[0]);
storage!.append(headerJSONPointer);
}

@char0n
Copy link
Member

char0n commented Jul 8, 2024

Addressed in #4230

@char0n char0n closed this as completed Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ApiDOM bug Something isn't working OpenAPI 3.1
Projects
None yet
Development

No branches or pull requests

2 participants