Files
dc-project/src/main/resources/openapi2.yaml
Fabrice Lecomte 0cf1aea9bf Test openapi schema of Register
Fix some routes
Improve Schema Validation
2021-03-16 00:53:10 +01:00

591 lines
16 KiB
YAML

openapi: 3.0.2
info:
version: ''
title: 'DC Project'
description: 'A free community program for create constitution'
paths:
/articles:
get:
summary: Get all articles
tags:
- article
operationId: getArticles
parameters:
- $ref: '#/components/parameters/page'
- $ref: '#/components/parameters/limit'
- $ref: '#/components/parameters/articleSort'
- $ref: '#/components/parameters/direction'
- $ref: '#/components/parameters/search'
- $ref: '#/components/parameters/createdBy'
- name: workgroup
in: query
description: ID of workgroup
example: 82a0e60a-bb55-dbc0-1c3d-0a804df2b5df
required: false
schema:
type: string
format: uuid
responses:
200:
description: The Article objects
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/Paginated'
- type: object
properties:
result:
type: array
maxItems: 50
items:
properties:
id:
type: string
format: uuid
title:
type: string
createdBy:
type: object
additionalProperties: false
properties:
id:
type: string
format: uuid
name:
type: object
properties:
firstName:
type: string
lastName:
type: string
email:
type: string
workgroup:
type: object
nullable: true
additionalProperties: false
properties:
id:
type: string
format: uuid
name:
type: string
draft:
type: boolean
post:
security:
- JWTAuth: []
summary: Create new Article
tags:
- article
operationId: insertArticle
requestBody:
required: true
content:
application/json:
schema:
required:
- title
- content
- description
- tags
properties:
title:
type: string
example:
Limit power of press
content:
type: string
example:
Lorem upsum...
description:
type: string
example:
I think is the bether choice
tags:
type: array
items:
type: string
default: [ ]
example: [ power, press ]
anonymous:
type: boolean
default: true
draft:
type: boolean
default: false
workgroup:
allOf:
- $ref: '#/components/schemas/UuidEntity'
- default: null
responses:
200:
description: Article created
content:
application/json:
schema:
properties:
id:
type: string
format: uuid
versionId:
type: string
format: uuid
versionNumber:
type: integer
401:
$ref: '#/components/responses/401'
/articles/{article}:
parameters:
- $ref: '#/components/parameters/article'
get:
security:
- JWTAuth: []
summary: Get one article
tags:
- article
operationId: getArticle
responses:
200:
description: The Article objects
content:
application/json:
schema:
$ref: '#/components/schemas/ArticleResponse'
/articles/{article}/versions:
parameters:
- $ref: '#/components/parameters/article'
get:
summary: Get all versions of articles
tags:
- article
operationId: getArticleVersions
responses:
200:
description: The versions of Article
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/Paginated'
- type: object
properties:
result:
type: array
items:
additionalProperties: false
properties:
id:
type: string
format: uuid
title:
type: string
draft:
type: boolean
lastVersion:
type: boolean
createdBy:
type: object
additionalProperties: false
properties:
id:
type: string
format: uuid
name:
type: object
properties:
firstName:
type: string
lastName:
type: string
email:
type: string
workgroup:
type: object
nullable: true
additionalProperties: false
properties:
id:
type: string
format: uuid
name:
type: string
/login:
post:
summary: sign in
tags:
- authentification
operationId: login
requestBody:
description: Login
required: true
content:
application/json:
schema:
required:
- username
- password
properties:
username:
type: string
description: username
example:
john-doe
password:
type: string
description: Pasword
example:
azerty
responses:
200:
description: return JWT
content:
text/plain:
schema:
type: string
format: byte
example:
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag'
application/json:
schema:
properties:
token:
type: string
example:
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag'
/register:
post:
summary: Create account
tags:
- authentification
operationId: register
requestBody:
content:
application/json:
schema:
type: object
required:
- name
- birthday
- email
- user
properties:
name:
type: object
required:
- firstName
- lastName
properties:
firstName:
type: string
example:
john
lastName:
type: string
example:
Doe
birthday:
type: string
format: 'date'
example: '1984-12-25'
email:
type: string
format: email
example: my.email@dc-project.fr
user:
type: object
required:
- username
- password
properties:
username:
type: string
example:
john-doe
password:
type: string
example:
azerty
format: password
responses:
200:
description: User created and JWT returned
content:
text/plain:
example:
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag'
application/json:
schema:
properties:
token:
type: string
example:
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag'
400:
description: Bad request
content:
application/json:
schema:
description: sdf
components:
parameters:
page:
name: page
in: query
description: The current page
example: 1
required: false
schema:
default: 1
type: integer
minimum: 1
limit:
name: limit
in: query
description: The number of object per page
example: 50
required: false
schema:
default: 50
type: integer
minimum: 1
maximum: 50
sort:
name: sort
in: query
description: The sort field name
example: firstName
required: false
schema:
type: string
articleSort:
name: sort
in: query
description: The sort field name
example: createdAt
required: false
schema:
type: string
enum:
- title
- createdAt
- vote
- popularity
direction:
name: direction
in: query
description: The sort direction
example: asc
required: false
schema:
type: string
default: asc
enum: [asc, desc]
search:
name: search
in: query
description: A text to seach
example: content50
required: false
schema:
type: string
createdBy:
name: createdBy
in: query
description: filter by Author
example: 4d673bfa-eaef-4290-b52f-85a9c8a7eba5
required: false
schema:
type: string
format: uuid
article:
name: article
in: path
required: true
description: the ID of article
example: d91aa0cd-61d6-83cc-41bb-8d5656e130f7
schema:
type: string
format: uuid
responses:
401:
description: Unautorized
content:
application/json:
schema:
description: noting
schemas:
UUID:
type: string
pattern: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
description: UUID
format: uuid
example:
e74be8e4-6823-47c4-bd1b-789725b2fa8e
UuidEntity:
properties:
id:
$ref: '#/components/schemas/UUID'
Paginated:
properties:
result:
type: array
maxItems: 50
items:
$ref: '#/components/schemas/UuidEntity'
count:
type: integer
minimum: 0
example: 1
currentPage:
type: integer
minimum: 0
example: 1
limit:
type: integer
minimum: 0
maximum: 50
example: 50
offset:
type: integer
minimum: 0
example: 1
total:
type: integer
minimum: 0
example: 1
ArticleResponse:
additionalProperties: false
required:
- id
- versionId
- versionNumber
- title
- anonymous
- content
- description
- tags
- draft
- lastVersion
- createdBy
- views
- opinions
- votes
properties:
id:
type: string
format: uuid
versionId:
type: string
format: uuid
versionNumber:
type: integer
minimum: 0
title:
type: string
anonymous:
type: boolean
content:
type: string
description:
type: string
tags:
type: array
items:
type: string
draft:
type: boolean
lastVersion:
type: boolean
createdAt:
type: string
format: 'date-time'
createdBy:
type: object
additionalProperties: false
required:
- id
- name
- email
properties:
id:
type: string
format: uuid
name:
type: object
required:
- firstName
- lastName
properties:
firstName:
type: string
lastName:
type: string
email:
type: string
workgroup:
type: object
nullable: true
additionalProperties: false
properties:
id:
type: string
format: uuid
name:
type: string
views:
additionalProperties: false
required:
- total
- unique
properties:
total:
type: integer
unique:
type: integer
opinions:
additionalProperties:
type: integer
example:
'good writed': 5
'to short': 19
votes:
additionalProperties: false
required:
- up
- neutral
- down
- total
- score
properties:
up:
type: integer
neutral:
type: integer
down:
type: integer
total:
type: integer
score:
type: integer
securitySchemes:
JWTAuth:
type: http
scheme: bearer
description: call /login to get token
bearerFormat: JWT
servers:
- description: localhost
url: http://localhost:8080
- description: production
url: http://dc-project.fr