Skip to content

Commit

Permalink
instantiate openapi v3 schema as draft4; refactor instantiation of v2…
Browse files Browse the repository at this point in the history
… and v3 schemas

v3's schema does not include a $schema so we specify this.
  • Loading branch information
notEthan committed Jan 24, 2022
1 parent 3acf364 commit 2ab929e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/scorpio/openapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class SemanticError < Error
autoload :OperationsScope, 'scorpio/openapi/operations_scope'

module V3
openapi_document_schema = JSI.new_schema(::YAML.load_file(Scorpio.root.join('documents/github.com/OAI/OpenAPI-Specification/blob/oas3-schema/schemas/v3.0/schema.yaml')))
openapi_document_schema = JSI::JSONSchemaOrgDraft04.new_schema(::YAML.load_file(Scorpio.root.join(
'documents/github.com/OAI/OpenAPI-Specification/blob/oas3-schema/schemas/v3.0/schema.yaml'
)))

# the schema represented by Scorpio::OpenAPI::V3::Schema will describe schemas itself, so we set it
# include on its schema module the jsi_schema_instance_modules that implement schema functionality.
Expand Down Expand Up @@ -96,7 +98,9 @@ module V3
raise(Bug) unless SchemaReference < JSI::Schema
end
module V2
openapi_document_schema = JSI.new_schema(::JSON.parse(Scorpio.root.join('documents/swagger.io/v2/schema.json').read))
openapi_document_schema = JSI.new_schema(::JSON.parse(Scorpio.root.join(
'documents/swagger.io/v2/schema.json'
).read))

# the schema represented by Scorpio::OpenAPI::V2::Schema will describe schemas itself, so we set it to
# include on its schema module the jsi_schema_instance_modules that implement schema functionality.
Expand Down

0 comments on commit 2ab929e

Please sign in to comment.