Skip to content

Commit

Permalink
fix: externalSchemas problem when using openapi (fastify#691)
Browse files Browse the repository at this point in the history
* fix cannot pass externalSchemas when using openapi configuration
  • Loading branch information
imjuni committed Nov 16, 2022
1 parent d504587 commit cb2f800
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/spec/openapi/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,16 @@ function prepareOpenapiMethod (schema, ref, openapiObject) {
if (schema.tags) openapiMethod.tags = schema.tags
if (schema.description) openapiMethod.description = schema.description
if (schema.externalDocs) openapiMethod.externalDocs = schema.externalDocs
if (schema.querystring) resolveCommonParams('query', parameters, schema.querystring, ref, openapiObject.definitions, securityIgnores.query)
if (schema.querystring) resolveCommonParams('query', parameters, schema.querystring, ref, openapiObject.components.schemas, securityIgnores.query)
if (schema.body) {
openapiMethod.requestBody = { content: {} }
resolveBodyParams(openapiMethod.requestBody, schema.body, schema.consumes, ref)
}
if (schema.params) resolveCommonParams('path', parameters, schema.params, ref, openapiObject.definitions)
if (schema.headers) resolveCommonParams('header', parameters, schema.headers, ref, openapiObject.definitions, securityIgnores.header)
if (schema.params) resolveCommonParams('path', parameters, schema.params, ref, openapiObject.components.schemas)
if (schema.headers) resolveCommonParams('header', parameters, schema.headers, ref, openapiObject.components.schemas, securityIgnores.header)
// TODO: need to documentation, we treat it same as the querystring
// fastify do not support cookies schema in first place
if (schema.cookies) resolveCommonParams('cookie', parameters, schema.cookies, ref, openapiObject.definitions, securityIgnores.cookie)
if (schema.cookies) resolveCommonParams('cookie', parameters, schema.cookies, ref, openapiObject.components.schemas, securityIgnores.cookie)
if (parameters.length > 0) openapiMethod.parameters = parameters
if (schema.deprecated) openapiMethod.deprecated = schema.deprecated
if (schema.security) openapiMethod.security = schema.security
Expand Down

0 comments on commit cb2f800

Please sign in to comment.