swagger-blocks 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +4 -0
- data/lib/swagger/blocks.rb +14 -0
- data/lib/swagger/blocks/class_methods.rb +16 -2
- data/lib/swagger/blocks/internal_helpers.rb +25 -0
- data/lib/swagger/blocks/node.rb +48 -10
- data/lib/swagger/blocks/nodes/all_of_node.rb +6 -5
- data/lib/swagger/blocks/nodes/callback_destination_node.rb +11 -0
- data/lib/swagger/blocks/nodes/callback_method_node.rb +16 -0
- data/lib/swagger/blocks/nodes/callback_node.rb +11 -0
- data/lib/swagger/blocks/nodes/component_node.rb +50 -0
- data/lib/swagger/blocks/nodes/content_node.rb +20 -0
- data/lib/swagger/blocks/nodes/example_node.rb +3 -1
- data/lib/swagger/blocks/nodes/flow_node.rb +11 -0
- data/lib/swagger/blocks/nodes/header_node.rb +4 -0
- data/lib/swagger/blocks/nodes/items_node.rb +1 -1
- data/lib/swagger/blocks/nodes/link_node.rb +11 -0
- data/lib/swagger/blocks/nodes/link_parameter_node.rb +8 -0
- data/lib/swagger/blocks/nodes/one_of_node.rb +11 -0
- data/lib/swagger/blocks/nodes/operation_node.rb +15 -0
- data/lib/swagger/blocks/nodes/parameter_node.rb +5 -0
- data/lib/swagger/blocks/nodes/path_node.rb +6 -0
- data/lib/swagger/blocks/nodes/property_node.rb +5 -0
- data/lib/swagger/blocks/nodes/request_body_node.rb +12 -0
- data/lib/swagger/blocks/nodes/response_node.rb +17 -4
- data/lib/swagger/blocks/nodes/root_node.rb +16 -2
- data/lib/swagger/blocks/nodes/schema_node.rb +9 -0
- data/lib/swagger/blocks/nodes/scopes_node.rb +0 -1
- data/lib/swagger/blocks/nodes/security_scheme_node.rb +5 -1
- data/lib/swagger/blocks/nodes/server_node.rb +12 -0
- data/lib/swagger/blocks/nodes/value_node.rb +8 -0
- data/lib/swagger/blocks/nodes/variable_node.rb +8 -0
- data/lib/swagger/blocks/nodes/vendor_extension_node.rb +9 -0
- data/lib/swagger/blocks/root.rb +8 -1
- data/lib/swagger/blocks/version.rb +1 -1
- data/spec/lib/swagger_v2_blocks_spec.rb +1 -1
- data/spec/lib/swagger_v3_api_declaration.json +592 -0
- data/spec/lib/swagger_v3_blocks_spec.rb +555 -0
- metadata +22 -4
@@ -0,0 +1,11 @@
|
|
1
|
+
module Swagger
|
2
|
+
module Blocks
|
3
|
+
module Nodes
|
4
|
+
class LinkNode < Node
|
5
|
+
def parameters(inline_keys = nil, &block)
|
6
|
+
self.data[:parameters] ||= Swagger::Blocks::Nodes::LinkParameterNode.call(version: version, inline_keys: inline_keys, &block)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -24,6 +24,21 @@ module Swagger
|
|
24
24
|
self.data[:security] ||= []
|
25
25
|
self.data[:security] << Swagger::Blocks::Nodes::SecurityRequirementNode.call(version: version, inline_keys: inline_keys, &block)
|
26
26
|
end
|
27
|
+
|
28
|
+
def request_body(inline_keys = nil, &block)
|
29
|
+
self.data[:requestBody] = Swagger::Blocks::Nodes::RequestBodyNode.call(version: version, inline_keys: inline_keys, &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def callback(event_name, inline_keys = nil, &block)
|
33
|
+
self.data[:callbacks] ||= {}
|
34
|
+
self.data[:callbacks][event_name] = Swagger::Blocks::Nodes::CallbackNode.call(version: version, inline_keys: inline_keys, &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
def server(inline_keys = nil, &block)
|
38
|
+
raise NotSupportedError unless is_openapi_3_0?
|
39
|
+
self.data[:servers] ||= []
|
40
|
+
self.data[:servers] << Swagger::Blocks::Nodes::ServerNode.call(version: version, inline_keys: inline_keys, &block)
|
41
|
+
end
|
27
42
|
end
|
28
43
|
end
|
29
44
|
end
|
@@ -10,6 +10,11 @@ module Swagger
|
|
10
10
|
def items(inline_keys = nil, &block)
|
11
11
|
self.data[:items] = Swagger::Blocks::Nodes::ItemsNode.call(version: version, inline_keys: inline_keys, &block)
|
12
12
|
end
|
13
|
+
|
14
|
+
def example(name, inline_keys = nil, &block)
|
15
|
+
self.data[:examples] ||= {}
|
16
|
+
self.data[:examples][name] = Swagger::Blocks::Nodes::ExampleNode.call(version: version, inline_keys: inline_keys, &block)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -18,6 +18,12 @@ module Swagger
|
|
18
18
|
self.data[:parameters] ||= []
|
19
19
|
self.data[:parameters] << Swagger::Blocks::Nodes::ParameterNode.call(version: version, inline_keys: inline_keys, &block)
|
20
20
|
end
|
21
|
+
|
22
|
+
def server(inline_keys = nil, &block)
|
23
|
+
raise NotSupportedError unless is_openapi_3_0?
|
24
|
+
self.data[:servers] ||= []
|
25
|
+
self.data[:servers] << Swagger::Blocks::Nodes::ServerNode.call(version: version, inline_keys: inline_keys, &block)
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
@@ -11,6 +11,11 @@ module Swagger
|
|
11
11
|
self.data[:properties].version = version
|
12
12
|
self.data[:properties].property(name, inline_keys, &block)
|
13
13
|
end
|
14
|
+
|
15
|
+
def one_of(&block)
|
16
|
+
self.data[:oneOf] ||= []
|
17
|
+
self.data[:oneOf] << Swagger::Blocks::Nodes::OneOfNode.call(version: version, &block)
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Swagger
|
2
|
+
module Blocks
|
3
|
+
module Nodes
|
4
|
+
class RequestBodyNode < Node
|
5
|
+
def content(type, inline_keys = nil, &block)
|
6
|
+
self.data[:content] ||= {}
|
7
|
+
self.data[:content][type] = Swagger::Blocks::Nodes::ContentNode.call(version: version, inline_keys: inline_keys, &block)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -13,10 +13,23 @@ module Swagger
|
|
13
13
|
self.data[:headers][head] = Swagger::Blocks::Nodes::HeaderNode.call(version: version, inline_keys: inline_keys, &block)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
self.data[:
|
19
|
-
|
16
|
+
def content(type, inline_keys = nil, &block)
|
17
|
+
self.data[:content] ||= {}
|
18
|
+
self.data[:content][type] = Swagger::Blocks::Nodes::ContentNode.call(version: version, inline_keys: inline_keys, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def example(name = nil, inline_keys = nil, &block)
|
22
|
+
if name.nil?
|
23
|
+
self.data[:example] = Swagger::Blocks::Nodes::ExampleNode.call(version: version, inline_keys: inline_keys, &block)
|
24
|
+
else
|
25
|
+
self.data[:examples] ||= {}
|
26
|
+
self.data[:examples][name] = Swagger::Blocks::Nodes::ExampleNode.call(version: version, inline_keys: inline_keys, &block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def link(name, inline_keys = nil, &block)
|
31
|
+
self.data[:links] ||= {}
|
32
|
+
self.data[:links][name] = Swagger::Blocks::Nodes::LinkNode.call(version: version, inline_keys: inline_keys, &block)
|
20
33
|
end
|
21
34
|
end
|
22
35
|
end
|
@@ -31,7 +31,7 @@ module Swagger
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def security(inline_keys = nil, &block)
|
34
|
-
raise NotSupportedError unless is_swagger_2_0?
|
34
|
+
raise NotSupportedError unless is_swagger_2_0? || is_openapi_3_0?
|
35
35
|
|
36
36
|
self.data[:security] ||= []
|
37
37
|
self.data[:security] << Swagger::Blocks::Nodes::SecurityRequirementNode.call(version: version, inline_keys: inline_keys, &block)
|
@@ -42,12 +42,26 @@ module Swagger
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def tag(inline_keys = nil, &block)
|
45
|
-
raise NotSupportedError unless is_swagger_2_0?
|
45
|
+
raise NotSupportedError unless is_swagger_2_0? || is_openapi_3_0?
|
46
46
|
|
47
47
|
self.data[:tags] ||= []
|
48
48
|
self.data[:tags] << Swagger::Blocks::Nodes::TagNode.call(version: version, inline_keys: inline_keys, &block)
|
49
49
|
end
|
50
50
|
|
51
|
+
def server(inline_keys = nil, &block)
|
52
|
+
raise NotSupportedError unless is_openapi_3_0?
|
53
|
+
|
54
|
+
self.data[:servers] ||= []
|
55
|
+
self.data[:servers] << Swagger::Blocks::Nodes::ServerNode.call(version: version, inline_keys: inline_keys, &block)
|
56
|
+
end
|
57
|
+
|
58
|
+
def extension(name, inline_keys = nil, &block)
|
59
|
+
raise NotSupportedError unless is_openapi_3_0?
|
60
|
+
|
61
|
+
self.data[name] ||= []
|
62
|
+
self.data[name] << Swagger::Blocks::Nodes::VendorExtensionNode.call(version: version, inline_keys: inline_keys, &block)
|
63
|
+
end
|
64
|
+
|
51
65
|
# Use 'tag' instead.
|
52
66
|
# @deprecated
|
53
67
|
alias_method :tags, :tag
|
@@ -24,6 +24,15 @@ module Swagger
|
|
24
24
|
def externalDocs(inline_keys = nil, &block)
|
25
25
|
self.data[:externalDocs] = Swagger::Blocks::Nodes::ExternalDocsNode.call(version: version, inline_keys: inline_keys, &block)
|
26
26
|
end
|
27
|
+
|
28
|
+
def example(inline_keys = nil, &block)
|
29
|
+
self.data[:example] = Swagger::Blocks::Nodes::ExampleNode.call(version: version, inline_keys: inline_keys, &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def one_of(&block)
|
33
|
+
self.data[:oneOf] ||= []
|
34
|
+
self.data[:oneOf] << Swagger::Blocks::Nodes::OneOfNode.call(version: version, &block)
|
35
|
+
end
|
27
36
|
end
|
28
37
|
end
|
29
38
|
end
|
@@ -1,13 +1,17 @@
|
|
1
1
|
module Swagger
|
2
2
|
module Blocks
|
3
3
|
module Nodes
|
4
|
-
# v2.0: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#security-scheme-object
|
5
4
|
class SecuritySchemeNode < Node
|
6
5
|
# TODO support ^x- Vendor Extensions
|
7
6
|
|
8
7
|
def scopes(inline_keys = nil, &block)
|
9
8
|
self.data[:scopes] = Swagger::Blocks::Nodes::ScopesNode.call(version: version, inline_keys: inline_keys, &block)
|
10
9
|
end
|
10
|
+
|
11
|
+
def flow(name, inline_keys = nil, &block)
|
12
|
+
self.data[:flows] ||= {}
|
13
|
+
self.data[:flows][name] = Swagger::Blocks::Nodes::FlowNode.call(version: version, inline_keys: inline_keys, &block)
|
14
|
+
end
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Swagger
|
2
|
+
module Blocks
|
3
|
+
module Nodes
|
4
|
+
class ServerNode < Node
|
5
|
+
def variable(name, inline_keys = nil, &block)
|
6
|
+
self.data[:variables] ||= {}
|
7
|
+
self.data[:variables][name] = Swagger::Blocks::Nodes::VariableNode.call(version: version, inline_keys: inline_keys, &block)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/swagger/blocks/root.rb
CHANGED
@@ -19,7 +19,14 @@ module Swagger
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
data[:root_node].
|
22
|
+
if data[:root_node].is_openapi_3_0?
|
23
|
+
data[:root_node].key(:paths, data[:path_nodes]) # Required, so no empty check.
|
24
|
+
if data[:component_node] && !data[:component_node].data.empty?
|
25
|
+
data[:root_node].key(:components, data[:component_node])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
data[:root_node].as_json(version: data[:root_node].version)
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
@@ -328,7 +328,7 @@ describe 'Swagger::Blocks v2' do
|
|
328
328
|
Swagger::Blocks.build_root_json([])
|
329
329
|
}.to raise_error(Swagger::Blocks::DeclarationError)
|
330
330
|
end
|
331
|
-
it 'errors if
|
331
|
+
it 'errors if multiple swagger_roots are declared' do
|
332
332
|
expect {
|
333
333
|
Swagger::Blocks.build_root_json([PetControllerV2, PetControllerV2])
|
334
334
|
}.to raise_error(Swagger::Blocks::DeclarationError)
|
@@ -0,0 +1,592 @@
|
|
1
|
+
{
|
2
|
+
"openapi": "3.0.0",
|
3
|
+
"info": {
|
4
|
+
"version": "1.0.1",
|
5
|
+
"title": "Swagger Petstore",
|
6
|
+
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
|
7
|
+
"termsOfService": "http://helloreverb.com/terms/",
|
8
|
+
"contact": {
|
9
|
+
"name": "Wordnik API Team"
|
10
|
+
},
|
11
|
+
"license": {
|
12
|
+
"name": "MIT"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"servers": [
|
16
|
+
{
|
17
|
+
"url": "http://petstore.swagger.io/v1",
|
18
|
+
"description": "Petstore API"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"url": "https://{subdomain}.site.com/{version}",
|
22
|
+
"description": "The main prod server",
|
23
|
+
"variables": {
|
24
|
+
"subdomain": {
|
25
|
+
"default": "production"
|
26
|
+
},
|
27
|
+
"version": {
|
28
|
+
"enum": [
|
29
|
+
"v1",
|
30
|
+
"v2"
|
31
|
+
],
|
32
|
+
"default": "v2"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
],
|
37
|
+
"security": [
|
38
|
+
{
|
39
|
+
"ApiKeyAuth": []
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"OAuth2": [
|
43
|
+
"read",
|
44
|
+
"write"
|
45
|
+
]
|
46
|
+
}
|
47
|
+
],
|
48
|
+
"x-tagGroups": [
|
49
|
+
{
|
50
|
+
"name": "Pets",
|
51
|
+
"tags": ["dogs", "cats"]
|
52
|
+
}
|
53
|
+
],
|
54
|
+
"tags": [
|
55
|
+
{
|
56
|
+
"name": "dogs",
|
57
|
+
"description": "Dogs"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"name": "cats",
|
61
|
+
"description": "Cats"
|
62
|
+
}
|
63
|
+
],
|
64
|
+
"paths": {
|
65
|
+
"/pets": {
|
66
|
+
"description": "Perform actions on pet resources",
|
67
|
+
"servers": [
|
68
|
+
{
|
69
|
+
"url": "http://petstore.swagger.io/",
|
70
|
+
"description": "Petstore API (without version prefix)"
|
71
|
+
}
|
72
|
+
],
|
73
|
+
"get": {
|
74
|
+
"summary": "List all pets",
|
75
|
+
"operationId": "listPets",
|
76
|
+
"tags": [
|
77
|
+
"pets"
|
78
|
+
],
|
79
|
+
"parameters": [
|
80
|
+
{
|
81
|
+
"name": "limit",
|
82
|
+
"in": "query",
|
83
|
+
"description": "How many items to return at one time (max 100)",
|
84
|
+
"required": false,
|
85
|
+
"schema": {
|
86
|
+
"type": "integer",
|
87
|
+
"format": "int32"
|
88
|
+
},
|
89
|
+
"examples": {
|
90
|
+
"large": {
|
91
|
+
"value": 100,
|
92
|
+
"summary": "Return a maximum of 100 results"
|
93
|
+
},
|
94
|
+
"small": {
|
95
|
+
"value": 5,
|
96
|
+
"summary": "Return a maximum of 5 results"
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
],
|
101
|
+
"servers": [
|
102
|
+
{
|
103
|
+
"url": "http://petstore.swagger.io/2.1/",
|
104
|
+
"description": "Petstore API (with version 2.1 prefix)"
|
105
|
+
}
|
106
|
+
],
|
107
|
+
"responses": {
|
108
|
+
"200": {
|
109
|
+
"description": "A paged array of pets",
|
110
|
+
"headers": {
|
111
|
+
"x-next": {
|
112
|
+
"description": "A link to the next page of responses",
|
113
|
+
"schema": {
|
114
|
+
"type": "string"
|
115
|
+
}
|
116
|
+
}
|
117
|
+
},
|
118
|
+
"content": {
|
119
|
+
"application/json": {
|
120
|
+
"schema": {
|
121
|
+
"$ref": "#/components/schemas/Pets"
|
122
|
+
},
|
123
|
+
"examples": {
|
124
|
+
"Rabbit": {
|
125
|
+
"value": {
|
126
|
+
"id": 10,
|
127
|
+
"name": "Rabbit"
|
128
|
+
}
|
129
|
+
},
|
130
|
+
"Cat": {
|
131
|
+
"$ref": "#/components/examples/Cat"
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
},
|
136
|
+
"links": {
|
137
|
+
"getPetById": {
|
138
|
+
"$ref": "#/components/links/GetPetById"
|
139
|
+
}
|
140
|
+
}
|
141
|
+
},
|
142
|
+
"default": {
|
143
|
+
"description": "unexpected error",
|
144
|
+
"content": {
|
145
|
+
"application/json": {
|
146
|
+
"schema": {
|
147
|
+
"$ref": "#/components/schemas/Error"
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
}
|
153
|
+
},
|
154
|
+
"post": {
|
155
|
+
"summary": "Create a pet",
|
156
|
+
"operationId": "createPets",
|
157
|
+
"tags": [
|
158
|
+
"pets"
|
159
|
+
],
|
160
|
+
"requestBody": {
|
161
|
+
"description": "Pet to add to the store",
|
162
|
+
"required": true,
|
163
|
+
"content": {
|
164
|
+
"application/json": {
|
165
|
+
"schema": {
|
166
|
+
"properties": {
|
167
|
+
"name": {
|
168
|
+
"type": "string"
|
169
|
+
}
|
170
|
+
},
|
171
|
+
"example": {
|
172
|
+
"name": "Fluffy"
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
},
|
178
|
+
"responses": {
|
179
|
+
"201": {
|
180
|
+
"description": "New Pet",
|
181
|
+
"content": {
|
182
|
+
"application/json": {
|
183
|
+
"schema": {
|
184
|
+
"$ref": "#/components/schemas/Pet"
|
185
|
+
}
|
186
|
+
}
|
187
|
+
},
|
188
|
+
"links": {
|
189
|
+
"getPetById": {
|
190
|
+
"operationId": "showPetById",
|
191
|
+
"parameters": {
|
192
|
+
"id": "$response.body#/id"
|
193
|
+
},
|
194
|
+
"description": "The `id` value returned in the response can be used as the `petId` parameter in `GET /pets/{petId}`."
|
195
|
+
}
|
196
|
+
}
|
197
|
+
},
|
198
|
+
"default": {
|
199
|
+
"description": "unexpected error",
|
200
|
+
"content": {
|
201
|
+
"application/json": {
|
202
|
+
"schema": {
|
203
|
+
"$ref": "#/components/schemas/Error"
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
210
|
+
},
|
211
|
+
"/pets/{petId}": {
|
212
|
+
"parameters": [
|
213
|
+
{
|
214
|
+
"name": "petId",
|
215
|
+
"in": "path",
|
216
|
+
"required": true,
|
217
|
+
"description": "The id of the pet to retrieve",
|
218
|
+
"schema": {
|
219
|
+
"type": "string"
|
220
|
+
}
|
221
|
+
}
|
222
|
+
],
|
223
|
+
"get": {
|
224
|
+
"summary": "Info for a specific pet",
|
225
|
+
"operationId": "showPetById",
|
226
|
+
"tags": [
|
227
|
+
"pets"
|
228
|
+
],
|
229
|
+
"responses": {
|
230
|
+
"200": {
|
231
|
+
"description": "Expected response to a valid request",
|
232
|
+
"content": {
|
233
|
+
"application/json": {
|
234
|
+
"schema": {
|
235
|
+
"$ref": "#/components/schemas/Pet"
|
236
|
+
}
|
237
|
+
}
|
238
|
+
}
|
239
|
+
},
|
240
|
+
"default": {
|
241
|
+
"description": "unexpected error",
|
242
|
+
"content": {
|
243
|
+
"application/json": {
|
244
|
+
"schema": {
|
245
|
+
"$ref": "#/components/schemas/Error"
|
246
|
+
}
|
247
|
+
}
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
},
|
252
|
+
"post": {
|
253
|
+
"summary": "Update info for a specific pet",
|
254
|
+
"operationId": "updatePetById",
|
255
|
+
"tags": [
|
256
|
+
"pets"
|
257
|
+
],
|
258
|
+
"requestBody": {
|
259
|
+
"$ref": "#/components/requestBodies/PetBody"
|
260
|
+
},
|
261
|
+
"responses": {
|
262
|
+
"200": {
|
263
|
+
"$ref": "#/components/responses/UpdatePetBodyResponse"
|
264
|
+
},
|
265
|
+
"default": {
|
266
|
+
"description": "unexpected error",
|
267
|
+
"content": {
|
268
|
+
"application/json": {
|
269
|
+
"schema": {
|
270
|
+
"$ref": "#/components/schemas/Error"
|
271
|
+
}
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}
|
275
|
+
}
|
276
|
+
},
|
277
|
+
"put": {
|
278
|
+
"summary": "Replace info for a specific pet",
|
279
|
+
"operationId": "replacePetById",
|
280
|
+
"tags": [
|
281
|
+
"pets"
|
282
|
+
],
|
283
|
+
"requestBody": {
|
284
|
+
"$ref": "#/components/requestBodies/PetBody"
|
285
|
+
},
|
286
|
+
"responses": {
|
287
|
+
"200": {
|
288
|
+
"$ref": "#/components/responses/ReplacePetBodyResponse"
|
289
|
+
},
|
290
|
+
"default": {
|
291
|
+
"description": "unexpected error",
|
292
|
+
"content": {
|
293
|
+
"application/json": {
|
294
|
+
"schema": {
|
295
|
+
"$ref": "#/components/schemas/Error"
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}
|
299
|
+
}
|
300
|
+
}
|
301
|
+
}
|
302
|
+
},
|
303
|
+
"/pets/{petId}/purchase": {
|
304
|
+
"post": {
|
305
|
+
"summary": "Purchase a specific pet",
|
306
|
+
"operationId": "purchasePetById",
|
307
|
+
"deprecated": true,
|
308
|
+
"tags": [
|
309
|
+
"pets"
|
310
|
+
],
|
311
|
+
"parameters": [
|
312
|
+
{"$ref": "#/components/parameters/petId"}
|
313
|
+
],
|
314
|
+
"requestBody": {
|
315
|
+
"description": "Pet order object",
|
316
|
+
"required": true,
|
317
|
+
"content": {
|
318
|
+
"application/json": {
|
319
|
+
"schema": {
|
320
|
+
"oneOf": [
|
321
|
+
{"$ref": "#/components/schemas/PetOrderRequest"},
|
322
|
+
{"$ref": "#/components/schemas/ComplexPetOrderRequest"}
|
323
|
+
]
|
324
|
+
},
|
325
|
+
"example": {
|
326
|
+
"id": 10,
|
327
|
+
"name": "Fluffy"
|
328
|
+
}
|
329
|
+
}
|
330
|
+
}
|
331
|
+
},
|
332
|
+
"responses": {
|
333
|
+
"201": {
|
334
|
+
"description": "Expected response to a valid request",
|
335
|
+
"content": {
|
336
|
+
"application/json": {
|
337
|
+
"schema": {
|
338
|
+
"$ref": "#/components/schemas/PetOrder"
|
339
|
+
}
|
340
|
+
}
|
341
|
+
}
|
342
|
+
},
|
343
|
+
"default": {
|
344
|
+
"description": "unexpected error",
|
345
|
+
"content": {
|
346
|
+
"application/json": {
|
347
|
+
"schema": {
|
348
|
+
"$ref": "#/components/schemas/Error"
|
349
|
+
}
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
},
|
354
|
+
"callbacks": {
|
355
|
+
"orderUpdated": {
|
356
|
+
"{$request.body#/webhook_url}": {
|
357
|
+
"post": {
|
358
|
+
"requestBody": {
|
359
|
+
"required": true,
|
360
|
+
"content": {
|
361
|
+
"application/json": {
|
362
|
+
"schema": {
|
363
|
+
"$ref": "#/components/schemas/OrderUpdated"
|
364
|
+
}
|
365
|
+
}
|
366
|
+
}
|
367
|
+
},
|
368
|
+
"responses": {
|
369
|
+
"200": {
|
370
|
+
"description": "The server must return an HTTP 200, otherwise delivery will be reattempted."
|
371
|
+
}
|
372
|
+
}
|
373
|
+
}
|
374
|
+
}
|
375
|
+
}
|
376
|
+
}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
},
|
380
|
+
"components": {
|
381
|
+
"schemas": {
|
382
|
+
"Pet": {
|
383
|
+
"required": [
|
384
|
+
"id",
|
385
|
+
"name"
|
386
|
+
],
|
387
|
+
"properties": {
|
388
|
+
"id": {
|
389
|
+
"type": "integer",
|
390
|
+
"format": "int64"
|
391
|
+
},
|
392
|
+
"name": {
|
393
|
+
"type": "string"
|
394
|
+
},
|
395
|
+
"tag_ids": {
|
396
|
+
"type": "array",
|
397
|
+
"items": {
|
398
|
+
"type": "integer",
|
399
|
+
"format": "int64",
|
400
|
+
"example": 1
|
401
|
+
},
|
402
|
+
"example": [1, 2, 3]
|
403
|
+
}
|
404
|
+
}
|
405
|
+
},
|
406
|
+
"Pets": {
|
407
|
+
"type": "array",
|
408
|
+
"items": {
|
409
|
+
"$ref": "#/components/schemas/Pet"
|
410
|
+
},
|
411
|
+
"example": [{"id": 10, "name": "Rover"}, {"id": 20, "name": "Felicity"}]
|
412
|
+
},
|
413
|
+
"PetOrderRequest": {
|
414
|
+
"required": [
|
415
|
+
"phone_number"
|
416
|
+
],
|
417
|
+
"properties": {
|
418
|
+
"phone_number": {
|
419
|
+
"type": "string"
|
420
|
+
},
|
421
|
+
"webhook_url": {
|
422
|
+
"type": "string"
|
423
|
+
}
|
424
|
+
}
|
425
|
+
},
|
426
|
+
"PetOrder": {
|
427
|
+
"required": [
|
428
|
+
"phone_number",
|
429
|
+
"id",
|
430
|
+
"status"
|
431
|
+
],
|
432
|
+
"properties": {
|
433
|
+
"id": {
|
434
|
+
"type": "integer",
|
435
|
+
"format": "int64"
|
436
|
+
},
|
437
|
+
"phone_number": {
|
438
|
+
"type": "string"
|
439
|
+
},
|
440
|
+
"webhook_url": {
|
441
|
+
"type": "string"
|
442
|
+
},
|
443
|
+
"status": {
|
444
|
+
"type": "string"
|
445
|
+
}
|
446
|
+
}
|
447
|
+
},
|
448
|
+
"OrderUpdated": {
|
449
|
+
"required": [
|
450
|
+
"order_id",
|
451
|
+
"status",
|
452
|
+
"phone_number"
|
453
|
+
],
|
454
|
+
"properties": {
|
455
|
+
"order_id": {
|
456
|
+
"type": "integer",
|
457
|
+
"format": "int64"
|
458
|
+
},
|
459
|
+
"phone_number": {
|
460
|
+
"type": "string"
|
461
|
+
},
|
462
|
+
"status": {
|
463
|
+
"type": "string"
|
464
|
+
}
|
465
|
+
},
|
466
|
+
"example": {
|
467
|
+
"order_id": 123,
|
468
|
+
"phone_number": "3125556666",
|
469
|
+
"status": "complete"
|
470
|
+
}
|
471
|
+
},
|
472
|
+
"Error": {
|
473
|
+
"required": [
|
474
|
+
"code",
|
475
|
+
"message"
|
476
|
+
],
|
477
|
+
"properties": {
|
478
|
+
"code": {
|
479
|
+
"type": "integer",
|
480
|
+
"format": "int32"
|
481
|
+
},
|
482
|
+
"message": {
|
483
|
+
"type": "string"
|
484
|
+
}
|
485
|
+
}
|
486
|
+
}
|
487
|
+
},
|
488
|
+
"requestBodies": {
|
489
|
+
"PetBody": {
|
490
|
+
"description": "A JSON object containing pet information",
|
491
|
+
"required": true,
|
492
|
+
"content": {
|
493
|
+
"application/json": {
|
494
|
+
"schema": {
|
495
|
+
"$ref": "#/components/schemas/Pet"
|
496
|
+
}
|
497
|
+
}
|
498
|
+
}
|
499
|
+
}
|
500
|
+
},
|
501
|
+
"responses" : {
|
502
|
+
"UpdatePetBodyResponse": {
|
503
|
+
"description": "Expected response to a valid request",
|
504
|
+
"content": {
|
505
|
+
"application/json": {
|
506
|
+
"schema": {
|
507
|
+
"$ref": "#/components/schemas/Pet"
|
508
|
+
}
|
509
|
+
}
|
510
|
+
}
|
511
|
+
},
|
512
|
+
"ReplacePetBodyResponse": {
|
513
|
+
"description": "Expected response to a valid request",
|
514
|
+
"content": {
|
515
|
+
"application/json": {
|
516
|
+
"schema": {
|
517
|
+
"$ref": "#/components/schemas/Pet"
|
518
|
+
}
|
519
|
+
}
|
520
|
+
}
|
521
|
+
}
|
522
|
+
},
|
523
|
+
"links": {
|
524
|
+
"GetPetById": {
|
525
|
+
"operationId": "showPetById",
|
526
|
+
"parameters": {
|
527
|
+
"petId": "$response.body#/id"
|
528
|
+
}
|
529
|
+
}
|
530
|
+
},
|
531
|
+
"examples": {
|
532
|
+
"PetExample": {
|
533
|
+
"value": {
|
534
|
+
"id": 1,
|
535
|
+
"name": "Rover"
|
536
|
+
},
|
537
|
+
"summary": "An example pet response"
|
538
|
+
},
|
539
|
+
"Cat": {
|
540
|
+
"value": {
|
541
|
+
"id": 1,
|
542
|
+
"name": "Felicity"
|
543
|
+
},
|
544
|
+
"summary": "An example cat response"
|
545
|
+
}
|
546
|
+
},
|
547
|
+
"securitySchemes": {
|
548
|
+
"BasicAuth": {
|
549
|
+
"type": "http",
|
550
|
+
"scheme": "basic"
|
551
|
+
},
|
552
|
+
"BearerAuth": {
|
553
|
+
"type": "http",
|
554
|
+
"scheme": "bearer"
|
555
|
+
},
|
556
|
+
"ApiKeyAuth": {
|
557
|
+
"type": "apiKey",
|
558
|
+
"in": "header",
|
559
|
+
"name": "X-API-Key"
|
560
|
+
},
|
561
|
+
"OpenID": {
|
562
|
+
"type": "openIdConnect",
|
563
|
+
"openIdConnectUrl": "https://example.com/.well-known/openid-configuration"
|
564
|
+
},
|
565
|
+
"OAuth2": {
|
566
|
+
"type": "oauth2",
|
567
|
+
"flows": {
|
568
|
+
"authorizationCode": {
|
569
|
+
"authorizationUrl": "https://example.com/oauth/authorize",
|
570
|
+
"tokenUrl": "https://example.com/oauth/token",
|
571
|
+
"scopes": {
|
572
|
+
"read": "Grants read access",
|
573
|
+
"write": "Grants write access",
|
574
|
+
"admin": "Grants access to admin operations"
|
575
|
+
}
|
576
|
+
}
|
577
|
+
}
|
578
|
+
}
|
579
|
+
},
|
580
|
+
"parameters": {
|
581
|
+
"petId": {
|
582
|
+
"name": "petId",
|
583
|
+
"in": "path",
|
584
|
+
"required": true,
|
585
|
+
"description": "The id of the pet to retrieve",
|
586
|
+
"schema": {
|
587
|
+
"type": "string"
|
588
|
+
}
|
589
|
+
}
|
590
|
+
}
|
591
|
+
}
|
592
|
+
}
|