MicroUtils/repos/ktor/crud.yml

199 lines
5.2 KiB
YAML
Raw Normal View History

2022-06-16 09:51:22 +00:00
openapi: "3.0.0"
info:
description: "This is a template for the CRUD repositories from [microutils](https://github.com/InsanusMokrassar/MicroUtils/tree/master/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/crud)"
2022-06-16 09:51:22 +00:00
version: "0.11.3"
title: "CRUD Repo"
contact:
email: "ovsyannikov.alexey95@gmail.com"
tags:
- name: "Read"
description: "Operations with `get` request in most cases"
- name: "Write"
description: "Operations with `post` request in most cases"
2022-06-16 09:51:22 +00:00
components:
parameters:
IdInQuery:
in: "query"
name: "id"
schema:
$ref: "#/components/schemas/Key"
PaginationInQueryPage:
in: "query"
name: "ppage"
description: "Page of pagination"
schema:
type: integer
2022-06-16 09:51:22 +00:00
required: false
PaginationInQuerySize:
in: "query"
name: "psize"
description: "Size of each page in pagination"
schema:
type: integer
2022-06-16 09:51:22 +00:00
required: false
schemas:
Key:
type: integer
description: "REWRITE THIS TYPE AS KEY IN SWAGGER FILE"
Value:
type: integer
description: "REWRITE THIS TYPE AS VALUE IN SWAGGER FILE"
NewValue:
type: integer
description: "REWRITE THIS TYPE AS NEW VALUE IN SWAGGER FILE"
Pair:
type: object
description: "Pair of objects"
properties:
first:
second:
PaginationResult:
type: object
properties:
page:
type: integer
description: "Page of pagination"
pagesNumber:
type: integer
description: "Count of pages with the size from this pagination"
size:
type: integer
description: "Size of each page in pagination"
results:
type: array
description: "Array of all elements on that page. Size of pagination and size of array can be different and it can be interpreted like current page is the last one"
items:
type: object
paths:
/getByPagination:
get:
tags:
- "Read"
parameters:
2022-06-16 09:51:22 +00:00
- $ref: "#/components/parameters/PaginationInQueryPage"
- $ref: "#/components/parameters/PaginationInQuerySize"
responses:
"200":
2022-06-04 10:47:22 +00:00
description: "Pagination with elements"
2022-06-16 09:51:22 +00:00
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/PaginationResult"
- properties:
results:
items:
$ref: "#/components/schemas/Value"
/getById:
get:
tags:
- "Read"
parameters:
2022-06-16 09:51:22 +00:00
- $ref: "#/components/parameters/IdInQuery"
required: true
responses:
"200":
description: "Result object"
2022-06-16 09:51:22 +00:00
content:
application/json:
schema:
$ref: "#/components/schemas/Value"
"204":
description: "No value by id"
/contains:
get:
tags:
- "Read"
parameters:
2022-06-16 09:51:22 +00:00
- $ref: "#/components/parameters/IdInQuery"
required: true
responses:
"200":
description: "Object with id availability in repo"
2022-06-16 09:51:22 +00:00
content:
application/json:
schema:
type: boolean
/count:
get:
tags:
- "Read"
responses:
"200":
description: "Amount of objects in repo"
2022-06-16 09:51:22 +00:00
content:
application/json:
schema:
type: integer
/create:
post:
tags:
- "Write"
2022-06-16 09:51:22 +00:00
requestBody:
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/NewValue"
responses:
"200":
description: "Objects has been created and saved"
2022-06-16 09:51:22 +00:00
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Value"
/update:
post:
tags:
- "Write"
2022-06-16 09:51:22 +00:00
requestBody:
content:
application/json:
schema:
type: array
items:
allOf:
- $ref: "#/components/schemas/Pair"
- properties:
first:
$ref: "#/components/schemas/Key"
second:
$ref: "#/components/schemas/NewValue"
responses:
"200":
description: "Objects has been updated"
2022-06-16 09:51:22 +00:00
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Value"
/deleteById:
post:
tags:
- "Write"
2022-06-16 09:51:22 +00:00
requestBody:
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Key"
responses:
"200":
description: "Objects has been updated"
2022-06-16 09:51:22 +00:00
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Value"