Skip to content

Commit e085227

Browse files
authored
Merge pull request #4468 from ralfhandl/3.1-schema-test-coverage
3.1: schema test coverage 100%
2 parents 177d639 + 6f5e6c4 commit e085227

17 files changed

+696
-0
lines changed
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
openapi: 3.1.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
components:
6+
links:
7+
Link-Object-with-body-property:
8+
operationId: getThing
9+
description: The "server" property was misspelled as "body" in a previous schema iteration, now fixed
10+
body:
11+
url: https://things.example.com
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
openapi: 3.1.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
components:
6+
callbacks:
7+
myCallback:
8+
'{$request.query.queryUrl}':
9+
post:
10+
requestBody:
11+
description: Callback payload
12+
content:
13+
application/json:
14+
schema:
15+
$ref: '#/components/schemas/SomePayload'
16+
responses:
17+
'200':
18+
description: callback successfully processed
19+
transactionCallback:
20+
'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}':
21+
post:
22+
requestBody:
23+
description: Callback payload
24+
content:
25+
application/json:
26+
schema:
27+
$ref: '#/components/schemas/SomePayload'
28+
responses:
29+
'200':
30+
description: callback successfully processed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
openapi: 3.1.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
components:
6+
schemas:
7+
GeneralError:
8+
type: object
9+
properties:
10+
code:
11+
type: integer
12+
format: int32
13+
message:
14+
type: string
15+
Category:
16+
type: object
17+
properties:
18+
id:
19+
type: integer
20+
format: int64
21+
name:
22+
type: string
23+
Tag:
24+
type: object
25+
properties:
26+
id:
27+
type: integer
28+
format: int64
29+
name:
30+
type: string
31+
parameters:
32+
skipParam:
33+
name: skip
34+
in: query
35+
description: number of items to skip
36+
required: true
37+
schema:
38+
type: integer
39+
format: int32
40+
limitParam:
41+
name: limit
42+
in: query
43+
description: max records to return
44+
required: true
45+
schema:
46+
type: integer
47+
format: int32
48+
responses:
49+
NotFound:
50+
description: Entity not found.
51+
IllegalInput:
52+
description: Illegal input for operation.
53+
GeneralError:
54+
description: General Error
55+
content:
56+
application/json:
57+
schema:
58+
$ref: '#/components/schemas/GeneralError'
59+
securitySchemes:
60+
api_key:
61+
type: apiKey
62+
name: api-key
63+
in: header
64+
petstore_auth:
65+
type: oauth2
66+
flows:
67+
implicit:
68+
authorizationUrl: https://example.org/api/oauth/dialog
69+
scopes:
70+
write:pets: modify pets in your account
71+
read:pets: read your pets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
openapi: 3.1.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
components:
6+
requestBodies:
7+
with-example:
8+
content:
9+
'application/json':
10+
schema:
11+
$ref: '#/components/schemas/Address'
12+
examples:
13+
foo:
14+
summary: A foo example
15+
value:
16+
foo: bar
17+
bar:
18+
summary: A bar example
19+
value:
20+
bar: baz
21+
application/xml:
22+
examples:
23+
xmlExample:
24+
summary: This is an example in XML
25+
externalValue: https://example.org/examples/address-example.xml
26+
text/plain:
27+
examples:
28+
textExample:
29+
summary: This is a text example
30+
externalValue: https://foo.bar/examples/address-example.txt
31+
parameters:
32+
with-example:
33+
name: zipCode
34+
in: query
35+
schema:
36+
type: string
37+
format: zip-code
38+
examples:
39+
zip-example:
40+
$ref: '#/components/examples/zip-example'
41+
responses:
42+
'200':
43+
description: your car appointment has been booked
44+
content:
45+
application/json:
46+
schema:
47+
$ref: '#/components/schemas/SuccessResponse'
48+
examples:
49+
confirmation-success:
50+
$ref: '#/components/examples/confirmation-success'
51+
application/x-www-form-urlencoded:
52+
schema:
53+
type: object
54+
properties:
55+
jsonValue:
56+
type: string
57+
encoding:
58+
jsonValue:
59+
contentType: application/json
60+
examples:
61+
jsonFormValue:
62+
description: 'The JSON string "json" as a form value'
63+
value: jsonValue=%22json%22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
openapi: 3.1.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
components:
6+
headers:
7+
X-Rate-Limit-Limit:
8+
description: The number of allowed requests in the current period
9+
deprecated: false
10+
schema:
11+
type: integer
12+
ETag:
13+
required: true
14+
content:
15+
text/plain:
16+
schema:
17+
type: string
18+
pattern: ^"
19+
Reference:
20+
$ref: '#/components/schemas/ETag'
21+
Style:
22+
schema:
23+
type: array
24+
style: simple
25+
explode: true
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# including External Documentation Object Example
2+
openapi: 3.1.0
3+
info:
4+
title: Example Pet Store App
5+
summary: A pet store manager.
6+
description: This is an example server for a pet store.
7+
termsOfService: https://example.com/terms/
8+
contact:
9+
name: API Support
10+
url: https://www.example.com/support
11+
12+
license:
13+
name: Apache 2.0
14+
url: https://www.apache.org/licenses/LICENSE-2.0.html
15+
version: 1.0.1
16+
externalDocs:
17+
description: Find more info here
18+
url: https://example.com
19+
components: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
openapi: 3.1.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
paths:
6+
/users/{id}:
7+
parameters:
8+
- name: id
9+
in: path
10+
required: true
11+
description: the user identifier, as userId
12+
schema:
13+
type: string
14+
get:
15+
responses:
16+
'200':
17+
description: the user being returned
18+
content:
19+
application/json:
20+
schema:
21+
type: object
22+
properties:
23+
uuid: # the unique user id
24+
type: string
25+
format: uuid
26+
links:
27+
address:
28+
# the target link operationId
29+
operationId: getUserAddress
30+
parameters:
31+
# get the `id` field from the request path parameter named `id`
32+
userid: $request.path.id
33+
address2:
34+
operationId: getUserAddressByUUID
35+
parameters:
36+
# get the `uuid` field from the `uuid` field in the response body
37+
userUuid: $response.body#/uuid
38+
UserRepositories:
39+
# returns array of '#/components/schemas/repository'
40+
operationRef: '#/paths/~12.0~1repositories~1%7Busername%7D/get'
41+
parameters:
42+
username: $response.body#/username
43+
UserRepositories2:
44+
# returns array of '#/components/schemas/repository'
45+
operationRef: https://na2.gigantic-server.com/#/paths/~12.0~1repositories~1%7Busername%7D/get
46+
parameters:
47+
username: $response.body#/username
48+
# the path item of the linked operation
49+
/users/{userid}/address:
50+
parameters:
51+
- name: userid
52+
in: path
53+
required: true
54+
description: the user identifier, as userId
55+
schema:
56+
type: string
57+
# linked operation
58+
get:
59+
operationId: getUserAddress
60+
responses:
61+
'200':
62+
description: the user's address
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# including Encoding Object examples
2+
openapi: 3.1.0
3+
info:
4+
title: API
5+
version: 1.0.0
6+
paths:
7+
/something:
8+
put:
9+
requestBody:
10+
content:
11+
application/json:
12+
schema:
13+
$ref: '#/components/schemas/Pet'
14+
examples:
15+
cat:
16+
summary: An example of a cat
17+
value:
18+
name: Fluffy
19+
petType: Cat
20+
color: White
21+
gender: male
22+
breed: Persian
23+
dog:
24+
summary: An example of a dog with a cat's name
25+
value:
26+
name: Puma
27+
petType: Dog
28+
color: Black
29+
gender: Female
30+
breed: Mixed
31+
frog:
32+
$ref: '#/components/examples/frog-example'
33+
application/x-www-form-urlencoded:
34+
schema:
35+
type: object
36+
properties:
37+
id:
38+
type: string
39+
format: uuid
40+
address:
41+
# complex types are stringified to support RFC 1866
42+
type: object
43+
properties: {}
44+
icon:
45+
# The default with "contentEncoding" is application/octet-stream,
46+
# so we need to set image media type(s) in the Encoding Object.
47+
type: string
48+
contentEncoding: base64url
49+
encoding:
50+
icon:
51+
contentType: image/png, image/jpeg
52+
multipart/form-data:
53+
schema:
54+
type: object
55+
properties:
56+
id:
57+
# default is `text/plain`
58+
type: string
59+
format: uuid
60+
addresses:
61+
# default based on the `items` subschema would be
62+
# `application/json`, but we want these address objects
63+
# serialized as `application/xml` instead
64+
description: addresses in XML format
65+
type: array
66+
items:
67+
$ref: '#/components/schemas/Address'
68+
profileImage:
69+
# default is application/octet-stream, but we can declare
70+
# a more specific image type or types
71+
type: string
72+
format: binary
73+
forCoverage:
74+
type: string
75+
forCoverage2:
76+
type: string
77+
encoding:
78+
addresses:
79+
# require XML Content-Type in utf-8 encoding
80+
# This is applied to each address part corresponding
81+
# to each address in he array
82+
contentType: application/xml; charset=utf-8
83+
profileImage:
84+
# only accept png or jpeg
85+
contentType: image/png, image/jpeg
86+
headers:
87+
X-Rate-Limit-Limit:
88+
description: The number of allowed requests in the current period
89+
schema:
90+
type: integer
91+
forCoverage:
92+
style: form
93+
explode: false
94+
allowReserved: true
95+
forCoverage2:
96+
style: spaceDelimited
97+
explode: true

0 commit comments

Comments
 (0)