Skip to content

Instantly share code, notes, and snippets.

@kirkgo
Created April 12, 2021 20:21
Show Gist options
  • Save kirkgo/114d08d7bf140a3f094778d2bd6aada5 to your computer and use it in GitHub Desktop.
Save kirkgo/114d08d7bf140a3f094778d2bd6aada5 to your computer and use it in GitHub Desktop.
Test - Json
openapi: 3.0.0
info:
version: "1.0.0-oas3"
title: Authentication Server
description: Spring Boot API that delivers authentication server functionality to the users of AutoPacker.
servers:
- url: 'http://dev.libane.tk:8080'
tags:
- name: members
description: Operations available to all our members.
- name: guests
description: Operations available to all our members, but also our guests.
paths:
/auth/register:
post:
tags:
- guests
summary: Register a new user
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
responses:
200:
description: User registered (verification token sent)
400:
description: Registration failed
/auth/login:
post:
tags:
- members
summary: Authenticate an existing user
requestBody:
content:
application/json:
schema:
type: object
required:
- username
- password
properties:
username:
type: string
password:
type: string
responses:
200:
description: Authentication success
401:
description: Invalid username or password
/auth/resendVerificationToken:
get:
tags:
- members
summary: Resend a verification token
responses:
200:
description: New token sent
400:
description: Couldn't create and send new token
/auth/registrationConfirmation:
get:
tags:
- members
summary: Verifies the user if token is valid
parameters:
- in: query
name: token
schema:
type: integer
description: Users' verification token
required: true
responses:
200:
description: User is verified
400:
description: Couldn't verify user
/auth/resetPasswordRequest:
get:
tags:
- members
summary: Performs a request to reset a users' password
parameters:
- in: query
name: email
schema:
type: string
description: The users' email
required: true
responses:
200:
description: Password reset request is a success
400:
description: Can't perform a password reset request
/auth/resetPasswordChange:
post:
tags:
- members
summary: Reset a users' password
requestBody:
content:
application/json:
schema:
type: object
required:
- token
- password
- password2
properties:
username:
type: string
password:
type: string
password2:
type: string
responses:
200:
description: Password reset successful
400:
description: Couldn't reset the users' password
/auth/changePassword:
post:
tags:
- members
summary: Change an authenticated users' password
requestBody:
content:
application/json:
schema:
type: object
required:
- oldPassword
- newPassword
properties:
password:
type: string
password2:
type: string
responses:
200:
description: Password change successful
400:
description: Couldn't change users' password
components:
# SECURITY #
securitySchemes:
'authKey':
type: apiKey
in: header
name: Cookie
# RESPONSES #
responses:
'403':
description: Access denied, token is not present or is invalid.
content:
application/json:
schema:
type: object
properties:
timestamp:
type: string
example: '2020-03-10T23:46:32.380+0000'
status:
type: integer
example: 403
error:
type: string
example: Forbidden
message:
type: string
example: Access Denied
path:
type: string
example: /auth/login
# OBJECTS #
schemas:
User:
type: object
description: Represents a user
required:
- id
- username
- email
- password
- role
properties:
id:
type: integer
example: 1
username:
type: string
example: Anonym101
email:
type: string
example: '[email protected]'
password:
type: string
example: 'SecretPassword123'
role:
$ref: '#/components/schemas/Role'
Role:
type: object
required:
- id
- name
- authorities
properties:
id:
type: integer
example: 1
name:
type: string
example: ADMIN
authority:
type: array
items:
$ref: '#/components/schemas/Authority'
Authority:
type: object
required:
- id
- authority
properties:
id:
type: integer
example: 1
authority:
type: string
example: ADMIN
Token:
type: object
description: parent of verificationtoken and resetpasswordtoken. In short, represent a token attached to the user
required:
- id
- value
- user
- expiryDate
properties:
id:
type: integer
example: 1
value:
type: string
example: 1241-35135-1351-13516
user:
$ref: '#/components/schemas/User'
expiryDate:
type: string
format: date-time
example: 2016-08-29T09:12:33.001Z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment