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

Charset content type identifier not supported #112

Closed
zlaroche opened this issue May 13, 2020 · 1 comment
Closed

Charset content type identifier not supported #112

zlaroche opened this issue May 13, 2020 · 1 comment

Comments

@zlaroche
Copy link

I've noticed that the source code doe does not properly register the response validator if an operation's content type is defined with the charset identifier, such as

content:
          application/json; charset=UTF-8:

The issue seems to be line 438 of node_modules/openapi-backend/validation.js, where it simply checks to see if the content is application/json, this missing an application/json with a charset identifier.

 const validator = this.getAjv(ValidationContext.Response);
        _.mapKeys(operation.responses, (res, status) => {
            const response = res;
            if (response.content && response.content['application/json'] && **response.content['application/json'].schema) {
                const validateFn = response.content['application/json'].schema;
                responseValidators[status] = validator.compile(validateFn);**
            }
            return null;
        });
        this.statusBasedResponseValidators[operationId] = responseValidators;
@LexLuengas
Copy link
Collaborator

As far as I can tell, neither the JSON spec nor the Media Type spec allow the usage of the "charset" parameter together with "application/json", so that would mean your example is part of an invalid OpenAPI document. For a better argumentation see axios/axios#2154 (comment) and request/request#383.

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

2 participants