Skip to content

Commit 7b29ee4

Browse files
authored
Merge pull request #4514 from baywet/feat/additional-operations
2 parents 85aad27 + 238aaca commit 7b29ee4

File tree

4 files changed

+179
-2
lines changed

4 files changed

+179
-2
lines changed

src/oas.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,8 @@ The path itself is still exposed to the documentation viewer but they will not k
932932
| <a name="path-item-head"></a>head | [Operation Object](#operation-object) | A definition of a HEAD operation on this path. |
933933
| <a name="path-item-patch"></a>patch | [Operation Object](#operation-object) | A definition of a PATCH operation on this path. |
934934
| <a name="path-item-trace"></a>trace | [Operation Object](#operation-object) | A definition of a TRACE operation on this path. |
935+
| <a name="path-item-query"></a>query | [Operation Object](#operation-object) | A definition of a QUERY operation, as defined in the most recent IETF draft ([draft-ietf-httpbis-safe-method-w-body-08](https://www.ietf.org/archive/id/draft-ietf-httpbis-safe-method-w-body-08.html) as of this writing) or its RFC successor, on this path. |
936+
| <a name="path-item-additional-operations"></a>additionalOperations | Map[`string`, [Operation Object](#operation-object)] | A map of additional operations on this path. The map key is the HTTP method with the same capitalization that is to be sent in the request. This map MUST NOT contain any entry for the methods that can be defined by other Operation Object fields (e.g. no `POST` entry, as the Operation Object field `post` is used for this method). |
935937
| <a name="path-item-servers"></a>servers | [[Server Object](#server-object)] | An alternative `servers` array to service all operations in this path. If a `servers` array is specified at the [OpenAPI Object](#oas-servers) level, it will be overridden by this value. |
936938
| <a name="path-item-parameters"></a>parameters | [[Parameter Object](#parameter-object) \| [Reference Object](#reference-object)] | A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a [name](#parameter-name) and [location](#parameter-in). The list can use the [Reference Object](#reference-object) to link to parameters that are defined in the [OpenAPI Object's `components.parameters`](#components-parameters). |
937939

@@ -985,7 +987,39 @@ This object MAY be extended with [Specification Extensions](#specification-exten
985987
},
986988
"style": "simple"
987989
}
988-
]
990+
],
991+
"additionalOperations": {
992+
"COPY": {
993+
"description": "Copies pet information based on ID",
994+
"summary": "Copies pets by ID",
995+
"operationId": "copyPetsById",
996+
"responses": {
997+
"200": {
998+
"description": "pet response",
999+
"content": {
1000+
"*/*": {
1001+
"schema": {
1002+
"type": "array",
1003+
"items": {
1004+
"$ref": "#/components/schemas/Pet"
1005+
}
1006+
}
1007+
}
1008+
}
1009+
},
1010+
"default": {
1011+
"description": "error payload",
1012+
"content": {
1013+
"text/html": {
1014+
"schema": {
1015+
"$ref": "#/components/schemas/ErrorModel"
1016+
}
1017+
}
1018+
}
1019+
}
1020+
}
1021+
}
1022+
}
9891023
}
9901024
```
9911025

@@ -1019,6 +1053,26 @@ parameters:
10191053
items:
10201054
type: string
10211055
style: simple
1056+
additionalOperations:
1057+
COPY:
1058+
description: Copies pet information based on ID
1059+
summary: Copies pets by ID
1060+
operationId: copyPetsById
1061+
responses:
1062+
'200':
1063+
description: pet response
1064+
content:
1065+
'*/*':
1066+
schema:
1067+
type: array
1068+
items:
1069+
$ref: '#/components/schemas/Pet'
1070+
default:
1071+
description: error payload
1072+
content:
1073+
text/html:
1074+
schema:
1075+
$ref: '#/components/schemas/ErrorModel'
10221076
```
10231077

10241078
#### Operation Object

src/schemas/validation/schema.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,24 @@ $defs:
230230
type: array
231231
items:
232232
$ref: '#/$defs/parameter-or-reference'
233+
additionalOperations:
234+
type: object
235+
additionalProperties:
236+
$ref: '#/$defs/operation'
237+
propertyNames:
238+
$comment: RFC9110 restricts methods to "1*tchar" in ABNF
239+
pattern: "^[a-zA-Z0-9!#$%&'*+.^_`|~-]+$"
240+
not:
241+
enum:
242+
- GET
243+
- PUT
244+
- POST
245+
- DELETE
246+
- OPTIONS
247+
- HEAD
248+
- PATCH
249+
- TRACE
250+
- QUERY
233251
get:
234252
$ref: '#/$defs/operation'
235253
put:
@@ -246,6 +264,8 @@ $defs:
246264
$ref: '#/$defs/operation'
247265
trace:
248266
$ref: '#/$defs/operation'
267+
query:
268+
$ref: '#/$defs/operation'
249269
$ref: '#/$defs/specification-extensions'
250270
unevaluatedProperties: false
251271

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
openapi: 3.2.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
paths:
6+
/pets/{id}:
7+
get:
8+
description: Returns pets based on ID
9+
summary: Find pets by ID
10+
operationId: getPetsById
11+
responses:
12+
'200':
13+
description: pet response
14+
content:
15+
'*/*':
16+
schema:
17+
type: array
18+
items:
19+
$ref: '#/components/schemas/Pet'
20+
default:
21+
description: error payload
22+
content:
23+
text/html:
24+
schema:
25+
$ref: '#/components/schemas/ErrorModel'
26+
parameters:
27+
- name: id
28+
in: path
29+
description: ID of pet to use
30+
required: true
31+
schema:
32+
type: array
33+
items:
34+
type: string
35+
style: simple
36+
additionalOperations:
37+
POST:
38+
description: Returns pets based on ID
39+
summary: Find pets by ID
40+
operationId: postPetsById
41+
requestBody:
42+
description: ID of pet to use
43+
required: true
44+
content:
45+
application/json:
46+
schema:
47+
type: array
48+
items:
49+
type: string
50+
responses:
51+
'200':
52+
description: pet response
53+
content:
54+
'*/*':
55+
schema:
56+
type: array
57+
items:
58+
$ref: '#/components/schemas/Pet'
59+
default:
60+
description: error payload
61+
content:
62+
text/html:
63+
schema:
64+
$ref: '#/components/schemas/ErrorModel'

tests/schema/pass/path-item-object-example.yaml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ paths:
2323
text/html:
2424
schema:
2525
$ref: '#/components/schemas/ErrorModel'
26+
query:
27+
description: Returns pets based on ID
28+
summary: Find pets by ID
29+
operationId: queryPetsById
30+
responses:
31+
'200':
32+
description: pet response
33+
content:
34+
'*/*':
35+
schema:
36+
type: array
37+
items:
38+
$ref: '#/components/schemas/Pet'
39+
default:
40+
description: error payload
41+
content:
42+
text/html:
43+
schema:
44+
$ref: '#/components/schemas/ErrorModel'
2645
parameters:
2746
- name: id
2847
in: path
@@ -32,4 +51,24 @@ paths:
3251
type: array
3352
items:
3453
type: string
35-
style: simple
54+
style: simple
55+
additionalOperations:
56+
COPY:
57+
description: Copies pet information based on ID
58+
summary: Copies pets by ID
59+
operationId: copyPetsById
60+
responses:
61+
'200':
62+
description: pet response
63+
content:
64+
'*/*':
65+
schema:
66+
type: array
67+
items:
68+
$ref: '#/components/schemas/Pet'
69+
default:
70+
description: error payload
71+
content:
72+
text/html:
73+
schema:
74+
$ref: '#/components/schemas/ErrorModel'

0 commit comments

Comments
 (0)