Last active
September 28, 2019 19:59
-
-
Save MikeRalphson/7ee0624fc1df70c0475717d89a5b6e4b to your computer and use it in GitHub Desktop.
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
openapi: 3.1.0-pre1 | |
info: | |
title: API | |
version: 1.0.0 | |
components: | |
parameters: | |
... | |
headers: | |
... | |
traits: | |
# each traitObject MUST have a parameters array XOR a response headers map | |
# + optionally, a summary, description and externalDocs object | |
# and a property: global (boolean, default false) to indicate it applies without exception to all operations/responses | |
# possibly could be expanded with requestBody, responses and links properties | |
# traits are layered in the order they are applied, and local conflicting definitions override those from traits | |
version: | |
global: true # applies to all pathItems | |
parameters: | |
- name: version | |
in: query | |
required: true | |
schema: | |
type: string | |
pagination: | |
parameters: | |
- $ref: '#/components/parameters/pageNo' | |
- $ref: '#/components/parameters/perPage' | |
externalDocs: | |
url: 'https://megadodopublications.com/api/pagination' | |
rateLimiting: | |
headers: | |
'X-Rate-Limited': | |
$ref: '#/components/headers/xRateLimited' | |
'X-Requests-Left': | |
$ref: '#/components/headers/xRequestsLeft' | |
externalDocs: | |
description: 'Find out more about rate limiting' | |
url: 'https://megadodopublications.com/api/rate-limiting' | |
paths: | |
/: | |
get: | |
traits: | |
- $ref: '#/components/traits/pagination' | |
responses: | |
'200': | |
description: OK | |
traits: | |
- $ref: '#/components/traits/rateLimiting' |
If you mean a globalTraits at the same level of "paths" it seems reasonable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ioggstream I can see the potential downside of that approach, but without some way to invoke traits globally, we're not necessarily answering the original requests for this feature.
What about a top-level
traits
orglobalTraits
array (containing trait objects or $refs)?