Created
February 25, 2020 21:36
-
-
Save restfulhead/50b8e67e1edb71b6be99ac34d7c45c5d to your computer and use it in GitHub Desktop.
openapi-example
This file contains hidden or 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.0.0' | |
info: | |
title: 'My awesome API' | |
version: '1.0' | |
security: | |
- apiKeyHeader: [] | |
- apiKeyQuery: [] | |
paths: | |
'/messages': | |
get: | |
operationId: get-messages | |
summary: Retrieves all messages | |
parameters: | |
- name: filter | |
in: query | |
description: Optional filter option(s) | |
required: false | |
style: deepObject | |
explode: true | |
schema: | |
type: object | |
additionalProperties: true | |
- name: fields | |
in: query | |
description: > | |
Use `fields=title,icon` to request only specific fields (in this example the title and icon) | |
required: false | |
style: form | |
explode: false | |
schema: | |
type: array | |
items: | |
type: string | |
- name: page | |
in: query | |
description: > | |
Use the `page[offset]` and `page[limit]` parameters to paginate through the results. | |
schema: | |
$ref: '#/components/schemas/PageParam' | |
style: deepObject | |
explode: true | |
required: false | |
- name: sort | |
in: query | |
description: > | |
Provide a single value or a comma separated list of fields to sort by, for example `sort=-sys.createdAt,title` | |
schema: | |
type: array | |
items: | |
type: string | |
explode: false | |
style: form | |
responses: | |
'200': | |
description: OK | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/MessageResultList' | |
'400': | |
$ref: '#/components/responses/BadRequest' | |
'401': | |
$ref: '#/components/responses/Unauthorized' | |
'404': | |
$ref: '#/components/responses/NotFound' | |
post: | |
operationId: post-message | |
summary: Creates a new message | |
requestBody: | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Message' | |
required: true | |
responses: | |
'200': | |
description: OK | |
'400': | |
$ref: '#/components/responses/BadRequest' | |
'401': | |
$ref: '#/components/responses/Unauthorized' | |
tags: [] | |
components: | |
responses: | |
BadRequest: | |
description: Invalid request | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Failure' | |
NotFound: | |
description: The specified resource was not found | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Failure' | |
Unauthorized: | |
description: Not authorized to perform this operation | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Failure' | |
UnprocessableEntity: | |
description: The provided entity contains invalid fields. | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Failure' | |
securitySchemes: | |
apiKeyHeader: | |
type: apiKey | |
name: Ocp-Apim-Subscription-Key | |
in: header | |
apiKeyQuery: | |
type: apiKey | |
name: subscription-key | |
in: query | |
schemas: | |
Links: | |
type: object | |
additionalProperties: | |
type: string | |
Failure: | |
type: object | |
required: | |
- errors | |
properties: | |
errors: | |
type: array | |
items: | |
'$ref': '#/components/schemas/Error' | |
uniqueItems: true | |
Error: | |
type: object | |
required: | |
- status | |
- code | |
- title | |
properties: | |
id: | |
description: A unique identifier for this particular occurrence of the problem. | |
type: string | |
links: | |
'$ref': '#/components/schemas/Links' | |
status: | |
description: The HTTP status code applicable to this problem, expressed as | |
a string value. | |
type: integer | |
minimum: 100 | |
maximum: 599 | |
code: | |
description: An application-specific error code, expressed as a string value. | |
type: string | |
title: | |
description: A short, human-readable summary of the problem. It **SHOULD NOT** | |
change from occurrence to occurrence of the problem, except for purposes | |
of localization. | |
type: string | |
detail: | |
description: A human-readable explanation specific to this occurrence of the | |
problem. | |
type: string | |
source: | |
type: object | |
properties: | |
pointer: | |
description: A JSON Pointer [RFC6901] to the associated entity in the | |
request document [e.g. "/data" for a primary data object, or "/data/attributes/title" | |
for a specific attribute]. | |
type: string | |
parameter: | |
description: A string indicating which query parameter caused the error. | |
type: string | |
LinkPagination: | |
type: object | |
properties: | |
first: | |
description: The first page of data | |
type: string | |
format: uri-reference | |
last: | |
description: The last page of data | |
type: string | |
format: uri-reference | |
prev: | |
description: The previous page of data | |
type: string | |
format: uri-reference | |
next: | |
description: The next page of data | |
type: string | |
format: uri-reference | |
OffsetPagination: | |
type: object | |
required: | |
- total | |
properties: | |
total: | |
type: integer | |
limit: | |
type: integer | |
offset: | |
type: integer | |
ResultList: | |
type: object | |
properties: | |
meta: | |
$ref: '#/components/schemas/OffsetPagination' | |
PageParam: | |
type: object | |
properties: | |
limit: | |
type: integer | |
offset: | |
type: integer | |
Message: | |
type: object | |
required: | |
- subject | |
- text | |
properties: | |
id: | |
type: string | |
subject: | |
type: string | |
text: | |
type: string | |
MessageResultList: | |
allOf: | |
- $ref: '#/components/schemas/ResultList' | |
- type: object | |
required: | |
- data | |
properties: | |
data: | |
type: array | |
items: | |
$ref: '#/components/schemas/Message' | |
links: | |
$ref: '#/components/schemas/LinkPagination' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment