Last active
July 27, 2020 10:18
-
-
Save urbontaitis/f843c9780f97a8be007903122bb2512d to your computer and use it in GitHub Desktop.
OpenAPI mock API schema
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.0.3" | |
info: | |
version: 1.0.0 | |
title: Swagger Video Rental Service | |
license: | |
name: MIT | |
servers: | |
- url: http://localhost:4000/api | |
paths: | |
/films: | |
get: | |
summary: List all films | |
operationId: listFilms | |
tags: | |
- films | |
parameters: | |
- name: limit | |
in: query | |
description: How many items to return at one time (max 100) | |
required: false | |
schema: | |
type: integer | |
format: int32 | |
responses: | |
'200': | |
description: A paged array of films | |
headers: | |
x-next: | |
description: A link to the next page of responses | |
schema: | |
type: string | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/Films" | |
default: | |
description: Internal server error | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/Error" | |
/films/{filmId}: | |
get: | |
summary: Info for a specific film | |
operationId: showFilmById | |
tags: | |
- films | |
parameters: | |
- name: filmId | |
in: path | |
required: true | |
description: The id of the film to retrieve | |
schema: | |
type: string | |
responses: | |
'200': | |
description: Expected response to a valid request | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/Film" | |
/points: | |
get: | |
summary: User points | |
operationId: points | |
tags: | |
- points | |
responses: | |
'401': | |
$ref: '#/components/responses/UnauthorizedError' | |
'200': | |
description: User points | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/Points" | |
/calculate: | |
post: | |
summary: Calculate a price | |
operationId: perform-calculation | |
requestBody: | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/CalculationForm" | |
tags: | |
- perform-calculation | |
responses: | |
'200': | |
description: succesfull operation | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/CalculationResponse" | |
/rent: | |
post: | |
summary: Rent films | |
operationId: perform-rent | |
requestBody: | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/RentFilmForm" | |
tags: | |
- perform-rent | |
responses: | |
'201': | |
description: succesfull operation | |
get: | |
summary: List of rentend films | |
operationId: list-rented-films | |
tags: | |
- list-rented-films | |
responses: | |
'200': | |
description: Rented films | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/RentedFilmResponse" | |
components: | |
securitySchemes: | |
basicAuth: | |
type: http | |
scheme: basic | |
schemas: | |
CalculationForm: | |
type: object | |
required: | |
- rentFilms | |
properties: | |
rentFilms: | |
type: array | |
items: | |
$ref: "#/components/schemas/CalculateFilm" | |
CalculationResponse: | |
type: object | |
required: | |
- rentFilms | |
properties: | |
rentFilms: | |
type: array | |
items: | |
$ref: "#/components/schemas/CalculateFilmResponse" | |
CalculateFilm: | |
type: object | |
required: | |
- filmId | |
- durationInDays | |
properties: | |
filmdId: | |
type: string | |
format: uuid | |
durationInDays: | |
type: integer | |
format: int32 | |
minimum: 0 | |
maximum: 10 | |
CalculateFilmResponse: | |
type: object | |
required: | |
- filmId | |
- durationInDays | |
- price | |
properties: | |
filmdId: | |
type: string | |
format: uuid | |
durationInDays: | |
type: integer | |
format: int32 | |
minimum: 0 | |
maximum: 10 | |
price: | |
type: integer | |
format: int32 | |
minimum: 30 | |
maximum: 400 | |
RentFilmForm: | |
type: object | |
required: | |
- rentFilms | |
properties: | |
rentFilms: | |
type: array | |
items: | |
$ref: "#/components/schemas/RentFilm" | |
RentFilmResponse: | |
type: object | |
required: | |
- rentFilms | |
properties: | |
rentFilms: | |
type: array | |
items: | |
$ref: "#/components/schemas/CalculateFilmResponse" | |
RentFilm: | |
type: object | |
required: | |
- filmId | |
- durationInDays | |
properties: | |
filmdId: | |
type: string | |
format: uuid | |
durationInDays: | |
type: integer | |
format: int32 | |
minimum: 0 | |
maximum: 10 | |
RentedFilmResponse: | |
type: object | |
required: | |
- filmId | |
- durationInDays | |
- price | |
- rentedAt | |
properties: | |
filmdId: | |
type: string | |
format: uuid | |
durationInDays: | |
type: integer | |
format: int32 | |
minimum: 0 | |
maximum: 10 | |
price: | |
type: integer | |
format: int32 | |
minimum: 30 | |
maximum: 400 | |
rentedAt: | |
type: string | |
format: date-time | |
returnedAt: | |
type: string | |
format: date-time | |
Film: | |
type: object | |
required: | |
- id | |
- title | |
- type | |
- price | |
properties: | |
id: | |
type: string | |
format: uuid | |
title: | |
type: string | |
maxLength: 20 | |
description: | |
type: string | |
maxLength: 500 | |
type: | |
type: string | |
enum: | |
- NEW | |
- REGULAR | |
- OLD | |
price: | |
type: integer | |
format: int32 | |
minimum: 30 | |
maximum: 40 | |
Films: | |
type: array | |
items: | |
$ref: "#/components/schemas/Film" | |
Points: | |
type: object | |
required: | |
- score | |
properties: | |
score: | |
type: integer | |
format: int32 | |
minimum: 0 | |
maximum: 100 | |
Error: | |
type: object | |
required: | |
- code | |
- message | |
properties: | |
code: | |
type: integer | |
format: int32 | |
message: | |
type: string | |
responses: | |
UnauthorizedError: | |
description: Authentication information is missing or invalid | |
headers: | |
WWW_Authenticate: | |
schema: | |
type: string | |
security: | |
- basicAuth: [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment