Skip to content

feat: adds additional operations for path item object #4514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
701d460
feat: adds additional operations for path item object
baywet Mar 28, 2025
524cc6f
chore: adds test data for additional operations
baywet Mar 28, 2025
b12f34b
fix: schema definition for outlawed properties
baywet Mar 28, 2025
692b413
fix: schema indentation and adds required keyword
baywet Mar 28, 2025
62dbf31
fix: 🤦 vincent needs a coffee
baywet Mar 28, 2025
15e99ca
Apply suggestions from code review
baywet Mar 28, 2025
72a29d7
Update tests/schema/pass/path-item-object-example.yaml
baywet Mar 28, 2025
2452ad1
chore: moves additional operations after the defined operations
baywet Mar 28, 2025
4cf5168
ci: adds a failing test for methods that should be defined on the par…
baywet Mar 28, 2025
cfdc4bc
Update tests/schema/fail/path-item-object-example.yaml
baywet Mar 28, 2025
d5141ec
chore: renames fail file to have more explicit definition of the case
baywet Mar 31, 2025
6ed7fe8
feat: adds query as "principal" operation type in path item
baywet Mar 31, 2025
61fee04
fix: excluded operations filter for additional operations
baywet Mar 31, 2025
d3c477c
docs: updates wording for additional operations exclusions
baywet Mar 31, 2025
2dc3e06
docs: updates additional operation samples to match hoisting of query
baywet Mar 31, 2025
e465abc
Merge branch 'feat/additional-operations' of https://github.com/baywe…
baywet Mar 31, 2025
3fb4d91
ci: fixes pass example test
baywet Mar 31, 2025
dd0cf16
docs: adds a query example to pass tests
baywet Mar 31, 2025
fc29d3a
docs: precisions around capitalization
baywet Mar 31, 2025
9a53a9d
ci: restricts to RFC9110 methods syntax
baywet Mar 31, 2025
621d1c3
docs: adds the query method to the spec
baywet Mar 31, 2025
ed5cfe4
fix: tchar definition
baywet Mar 31, 2025
480dc75
Fix regex character class
handrews Mar 31, 2025
1826161
Fix character class in regular expression
handrews Mar 31, 2025
3ee2d24
Undo my incorrect additional "fix"
handrews Mar 31, 2025
0c4f6be
docs: typo fix in html attribute name
baywet Apr 1, 2025
238aaca
docs: schema regex fix
baywet Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion src/oas.md
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,8 @@ The path itself is still exposed to the documentation viewer but they will not k
| <a name="path-item-head"></a>head | [Operation Object](#operation-object) | A definition of a HEAD operation on this path. |
| <a name="path-item-patch"></a>patch | [Operation Object](#operation-object) | A definition of a PATCH operation on this path. |
| <a name="path-item-trace"></a>trace | [Operation Object](#operation-object) | A definition of a TRACE operation on this path. |
| <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. |
| <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). |
| <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. |
| <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). |

Expand Down Expand Up @@ -985,7 +987,39 @@ This object MAY be extended with [Specification Extensions](#specification-exten
},
"style": "simple"
}
]
],
"additionalOperations": {
"COPY": {
"description": "Copies pet information based on ID",
"summary": "Copies pets by ID",
"operationId": "copyPetsById",
"responses": {
"200": {
"description": "pet response",
"content": {
"*/*": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
},
"default": {
"description": "error payload",
"content": {
"text/html": {
"schema": {
"$ref": "#/components/schemas/ErrorModel"
}
}
}
}
}
}
}
}
```

Expand Down Expand Up @@ -1019,6 +1053,26 @@ parameters:
items:
type: string
style: simple
additionalOperations:
COPY:
description: Copies pet information based on ID
summary: Copies pets by ID
operationId: copyPetsById
responses:
'200':
description: pet response
content:
'*/*':
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
default:
description: error payload
content:
text/html:
schema:
$ref: '#/components/schemas/ErrorModel'
```

#### Operation Object
Expand Down
20 changes: 20 additions & 0 deletions src/schemas/validation/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,24 @@ $defs:
type: array
items:
$ref: '#/$defs/parameter-or-reference'
additionalOperations:
type: object
additionalProperties:
$ref: '#/$defs/operation'
propertyNames:
$comment: RFC9110 restricts methods to "1*tchar" in ABNF
pattern: "^[a-zA-Z0-9!#$%&'*+.^_`|~-]+$"
not:
enum:
- GET
- PUT
- POST
- DELETE
- OPTIONS
- HEAD
- PATCH
- TRACE
- QUERY
get:
$ref: '#/$defs/operation'
put:
Expand All @@ -246,6 +264,8 @@ $defs:
$ref: '#/$defs/operation'
trace:
$ref: '#/$defs/operation'
query:
$ref: '#/$defs/operation'
$ref: '#/$defs/specification-extensions'
unevaluatedProperties: false

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
openapi: 3.2.0
info:
title: API
version: 1.0.0
paths:
/pets/{id}:
get:
description: Returns pets based on ID
summary: Find pets by ID
operationId: getPetsById
responses:
'200':
description: pet response
content:
'*/*':
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
default:
description: error payload
content:
text/html:
schema:
$ref: '#/components/schemas/ErrorModel'
parameters:
- name: id
in: path
description: ID of pet to use
required: true
schema:
type: array
items:
type: string
style: simple
additionalOperations:
POST:
description: Returns pets based on ID
summary: Find pets by ID
operationId: postPetsById
requestBody:
description: ID of pet to use
required: true
content:
application/json:
schema:
type: array
items:
type: string
responses:
'200':
description: pet response
content:
'*/*':
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
default:
description: error payload
content:
text/html:
schema:
$ref: '#/components/schemas/ErrorModel'
41 changes: 40 additions & 1 deletion tests/schema/pass/path-item-object-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ paths:
text/html:
schema:
$ref: '#/components/schemas/ErrorModel'
query:
description: Returns pets based on ID
summary: Find pets by ID
operationId: queryPetsById
responses:
'200':
description: pet response
content:
'*/*':
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
default:
description: error payload
content:
text/html:
schema:
$ref: '#/components/schemas/ErrorModel'
parameters:
- name: id
in: path
Expand All @@ -32,4 +51,24 @@ paths:
type: array
items:
type: string
style: simple
style: simple
additionalOperations:
COPY:
description: Copies pet information based on ID
summary: Copies pets by ID
operationId: copyPetsById
responses:
'200':
description: pet response
content:
'*/*':
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
default:
description: error payload
content:
text/html:
schema:
$ref: '#/components/schemas/ErrorModel'