You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the swagger spec, all response objects are optional, when you specify them in the required attribute they become mandatory, only the response_validator sets the requirement default to True, instead of False.
Super, the thing that im missing though is a way to set the options, so I saw you relaxed the json-schema versions somewhat . But now we still need to do something like this:
config/initializers/rswag_ui.rb
Rswag::Ui.configuredo |c|
# List the Swagger endpoints that you want to be documented through the swagger-ui# The first parameter is the path (absolute or relative to the UI host) to the corresponding# JSON endpoint and the second is a title that will be displayed in the document selector# NOTE: If you're using rspec-api to expose Swagger files (under swagger_root) as JSON endpoints,# then the list below should correspond to the relative paths for those endpointsc.swagger_endpoint'/api-docs/v1/swagger.json','v1'c.config_object.merge!({deepLinking: true,filter: true,syntaxHighlight: {activate: true,theme: 'monokai'},tryItOutEnabled: true,persistAuthorization: true,defaultModelsExpandDepth: 10,defaultModelExpandDepth: 10})end# https://github.com/rswag/rswag/issues/704moduleResponseValidatordefvalidation_options_from(metadata)is_strict= !!metadata.fetch(:swagger_strict_schema_validation,@config.swagger_strict_schema_validation){struct: is_strict,noAdditionalProperties: true}endendRswag::Specs::ResponseValidator.prependResponseValidator
or adding a freeform object that gets injected directly with a clear reference to the config options from json-schema, this way you don't need to make a abstraction layer ontop of this gem, and you don't own the options or need to change the config when the underlying package changes.
Describe the bug
According to the swagger spec, all response objects are optional, when you specify them in the
required
attribute they become mandatory, only the response_validator sets the requirement default to True, instead of False.Issue is when you set swagger_strict_schema_validation to true, it actually sets
strict: true
onJSON::Validator.validate!(schema, yaml, :strict => true)
and when you set strict to true here, all fields become required. But this contradicts the swagger spec. I think instead of strict, you should usenoAdditionalProperties
here: https://github.com/rswag/rswag/blob/master/rswag-specs/lib/rswag/specs/response_validator.rb#L67C26-L67C26 but the setting is set here: https://github.com/rswag/rswag/blob/master/rswag-specs/lib/rswag/specs/response_validator.rb#L75like so:
Resulting in my spec failing
even though this
current_cach_value
attribute is not in my required list.Dependency versions
The version of are you using for:
Relates to which version of OAS (OpenAPI Specification)
The text was updated successfully, but these errors were encountered: