-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from interagent/feature/openapi3_example
add openapi3 example
- Loading branch information
Showing
10 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,7 @@ | |
*.sw* | ||
tags | ||
Gemfile.lock | ||
!/examples/openapi3/Gemfile.lock | ||
!/examples/json_schema/Gemfile.lock | ||
.DS_Store | ||
/coverage/ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "committee", path: "../../" | ||
gem "sinatra" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
PATH | ||
remote: ../.. | ||
specs: | ||
committee (3.3.0) | ||
json_schema (~> 0.14, >= 0.14.3) | ||
openapi_parser (>= 0.6.1) | ||
rack (>= 1.5) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
json_schema (0.20.8) | ||
mustermann (1.1.1) | ||
ruby2_keywords (~> 0.0.1) | ||
openapi_parser (0.10.0) | ||
rack (2.2.2) | ||
rack-protection (2.0.8.1) | ||
rack | ||
ruby2_keywords (0.0.2) | ||
sinatra (2.0.8.1) | ||
mustermann (~> 1.0) | ||
rack (~> 2.0) | ||
rack-protection (= 2.0.8.1) | ||
tilt (~> 2.0) | ||
tilt (2.0.10) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
committee! | ||
sinatra | ||
|
||
BUNDLED WITH | ||
1.17.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require "committee" | ||
require "json" | ||
require "securerandom" | ||
require "sinatra/base" | ||
require "yaml" | ||
|
||
class App < Sinatra::Base | ||
SCHEMA_PATH = File.expand_path("../openapi.yaml", __FILE__) | ||
use Committee::Middleware::RequestValidation, schema_path: SCHEMA_PATH, strict: true, raise: true | ||
use Committee::Middleware::ResponseValidation, schema_path: SCHEMA_PATH | ||
|
||
# This handler is called into, but its response is ignored. | ||
get "/apps" do | ||
end | ||
|
||
# This handler suppresses the stubbed response and returns its own. | ||
get "/posts" do | ||
content_type :json | ||
status 204 | ||
end | ||
|
||
post "/dont_allow_additional_parameter" do | ||
content_type :json | ||
status 204 | ||
end | ||
end | ||
|
||
if __FILE__ == $0 | ||
App.run! port: 5000 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: api-test | ||
version: '1.0' | ||
servers: | ||
- url: 'http://localhost:3000' | ||
description: dev | ||
paths: | ||
/posts: | ||
get: | ||
parameters: | ||
- in: query | ||
name: page | ||
required: true | ||
schema: | ||
type: integer | ||
responses: | ||
'200': | ||
description: No Content | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
|
||
/dont_allow_additional_parameter: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
additionalProperties: false | ||
required: | ||
- only_param | ||
properties: | ||
only_param: | ||
type: string | ||
responses: | ||
'200': | ||
description: No Content | ||
content: | ||
application/json: | ||
schema: | ||
type: object |