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

Bug: OpenAPIResponseValidatorArgs responses object incorrectly defined #888

Open
sazazi opened this issue Sep 26, 2023 · 0 comments
Open

Comments

@sazazi
Copy link

sazazi commented Sep 26, 2023

I am currently trying to validate some responses using the openapi-response-validator package. However, the responses that I'd like to pass to the OpenAPIResponseValidator look something like:

responses: {
  '204': {
    description: 'The message was produced successfully'
  },
  '400': {
    description: 'Bad request',
    content: {
      'application/json': {
        schema: {
          $ref: '#/components/schemas/Error'
        },
        examples: {
          internalError: {
            value: {
              message: 'INTERNAL_ERROR'
            }
          }
        }
      }
    }
  }
}

These responses are valid and comply with the OpenAPI 3 schema, however, the OpenAPIResponseValidatorArgs only have schema present in the Response object defined which does not comply with the OpenAPI 3 Schema. It should be as follows:

  responses: {
    [responseCode: string]: OpenAPIV2.ResponseObject | OpenAPIV3.ResponseObject | OpenAPIV3_1.ResponseObject;
  };

Furthermore, the example given in the openapi-response-validator README also does not work for the same reason, as description is not defined in the response object.

As it currently is, the openapi-response-validator does not validate OpenAPI 3 responses due to incorrect/missing args. Can these OpenAPIResponseValidatorArgs be updated to comply with the OpenAPI 3 spec and the validation of the response updated accordingly, please?

@sazazi sazazi changed the title OpenAPIResponseValidatorArgs responses object incorrectly defined Bug: OpenAPIResponseValidatorArgs responses object incorrectly defined Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant