Updates specs to add 3.0 compliant structure and tests around the new schema/structure

This commit is contained in:
Jay Danielian
2019-07-20 12:29:44 -04:00
parent 04564d933f
commit 4baf5efd11
6 changed files with 33 additions and 23 deletions

View File

@@ -43,7 +43,9 @@ module Rswag
# TODO: setup travis CI?
# MUST HAVES
# TODO: look at integrating and documenting the rest of the responses in the blog_spec and get a clean 3.0 output
# TODO: fix the specs in the rswag-specs gem
# TODO: look at handling different ways schemas can be defined in 3.0 for requestBody and response
# can we handle all of them?
# Then can look at handling different request_body things like $ref, etc
# TODO: look at adding request_body method to handle diffs in Open API 2.0 to 3.0
# TODO: look at adding examples in content request_body

View File

@@ -40,7 +40,8 @@ module Rswag
def derive_security_params(metadata, swagger_doc)
requirements = metadata[:operation][:security] || swagger_doc[:security] || []
scheme_names = requirements.flat_map(&:keys)
schemes = (swagger_doc[:components][:securitySchemes] || {}).slice(*scheme_names).values
components = swagger_doc[:components] || {}
schemes = (components[:securitySchemes] || {}).slice(*scheme_names).values
schemes.map do |scheme|
param = scheme[:type] == :apiKey ? scheme.slice(:name, :in) : { name: 'Authorization', in: :header }

View File

@@ -42,7 +42,8 @@ module Rswag
response_schema = metadata[:response][:schema]
return if response_schema.nil?
components_schemas = { components: { schemas: swagger_doc[:components][:schemas] } }
components = swagger_doc[:components] || {}
components_schemas = { components: { schemas: components[:schemas] } }
validation_schema = response_schema
.merge('$schema' => 'http://tempuri.org/rswag/specs/extended_schema')