Skip to content

Commit

Permalink
Merge pull request #223 from interagent/feature/openapi_version
Browse files Browse the repository at this point in the history
Support OpenAPI 3 patch version
  • Loading branch information
ota42y authored May 15, 2019
2 parents 810fadc + ed39431 commit 1e58b85
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Unreleased

3.0.2 2019-05-15
Support OpenAPI 3 patch version (#223)

3.0.1 2019-03-18
Correct use of `filepath` to `schema_path` (#216)

Expand Down
2 changes: 1 addition & 1 deletion committee.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "committee"
s.version = "3.0.1"
s.version = "3.0.2"

s.summary = "A collection of Rack middleware to support JSON Schema."

Expand Down
2 changes: 1 addition & 1 deletion lib/committee/drivers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def self.load_from_file(schema_path)
# @param [Hash] hash
# @return [Committee::Driver]
def self.load_from_data(hash)
if hash['openapi'] == '3.0.0'
if hash['openapi']&.start_with?('3.0.')
parser = OpenAPIParser.parse(hash)
return Committee::Drivers::OpenAPI3.new.parse(parser)
end
Expand Down
26 changes: 26 additions & 0 deletions test/data/openapi3/3_0_1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
openapi: 3.0.1
info:
version: 1.0.0
title: OpenAPI3 Test
description: A Sample file
paths:
/characters:
get:
description: get characters
parameters:
- name: school_name
in: query
description: school name to filter by
required: false
style: form
schema:
type: array
items:
type: string
responses:
'200':
description: success
content:
application/json:
schema:
type: object
6 changes: 6 additions & 0 deletions test/drivers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
assert_kind_of Committee::Drivers::OpenAPI3::Schema, s
end

it 'load OpenAPI 3 (patch version 3.0.1)' do
s = Committee::Drivers.load_from_file(open_api_3_0_1_schema_path)
assert_kind_of Committee::Drivers::Schema, s
assert_kind_of Committee::Drivers::OpenAPI3::Schema, s
end

it 'errors on an unsupported file extension' do
e = assert_raises(StandardError) do
Committee::Drivers.load_from_file('test.xml')
Expand Down
3 changes: 3 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ def open_api_3_schema_path
"./test/data/openapi3/normal.yaml"
end

def open_api_3_0_1_schema_path
"./test/data/openapi3/3_0_1.yaml"
end

0 comments on commit 1e58b85

Please sign in to comment.