Skip to content

Instantly share code, notes, and snippets.

@JLNNN
Created April 19, 2018 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JLNNN/5988f37e76f4d897db25a70b728d64b7 to your computer and use it in GitHub Desktop.
Save JLNNN/5988f37e76f4d897db25a70b728d64b7 to your computer and use it in GitHub Desktop.
openapi: 3.0.0
servers:
- url: https://localhost/
info:
description: My API description
title: My API title
version: '1.0'
paths:
/some-data/:
get:
summary: Retrieve some-data
tags:
- some-data
operationId: some-data_list
responses:
200:
description: OK
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/Pagination'
- type: object
- properties:
results:
type: array
items:
allOf:
- $ref: '#/components/schemas/SomeData'
- example:
allOf:
- $ref: '#/components/examples/SomeDataOutput/value'
401:
$ref: '#/components/responses/Unauthorized'
403:
$ref: '#/components/responses/Forbidden'
components:
examples:
SomeDataOutput:
summary: A sample response data
value:
id: 1
contact_email: test@test.com
responses:
Forbidden:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ForbiddenError'
Unauthorized:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthorizedError'
schemas:
Error:
title: General Error
properties:
detail:
type: string
required:
- detail
example:
detail: Error explanation.
ForbiddenError:
title: Forbidden
allOf:
- $ref: '#/components/schemas/Error'
example:
detail: You do not have permission to perform this action.
Pagination:
properties:
count:
type: integer
example: 1
next:
type: string
example: https://localhost/resources/?page=1&page_size=1
previous:
type: string
example: https://localhost/resources/?page=1&page_size=1
SomeData:
description: The data resource that represents some data
type: object
properties:
id:
type: number
format: int64
readOnly: true
contact_email:
description: An email address in case there are problems or questions regarding
the data - normally, the email address of the developer account is
used. While listed as optional, we recommend providing this information.
type: string
format: email
required:
- id
- contact_email
UnauthorizedError:
title: Unauthorized
allOf:
- $ref: '#/components/schemas/Error'
example:
detail: Authentication credentials were not provided.
securitySchemes:
oauth2:
description: 'Get access to data while protecting your account credentials.
OAuth2 is also a safer and more secure way to give you access.
'
type: oauth2
flows:
implicit:
authorizationUrl: https://localhost/auth/realms/project/protocol/openid-connect/auth?nonce=jwt_login
scopes: {}
clientCredentials:
tokenUrl: https://localhost/auth/realms/project/protocol/openid-connect/token
scopes: {}
password:
tokenUrl: https://localhost/auth/realms/project/protocol/openid-connect/token
scopes: {}
security:
- oauth2: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment