API-first with openapiprocessor and modelmapper
This commit is contained in:
306
src/main/resources/api-definition.yaml
Normal file
306
src/main/resources/api-definition.yaml
Normal file
@ -0,0 +1,306 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: Hostsharing hsadmin-ng API
|
||||
version: v0
|
||||
servers:
|
||||
- url: http://localhost:8080
|
||||
description: Local development default URL.
|
||||
|
||||
paths:
|
||||
|
||||
/api/customers:
|
||||
get:
|
||||
summary: Returns a list of (optionally filtered) customers.
|
||||
description: Returns the list of (optionally filtered) customers which are visible to the current user or any of it's assumed roles.
|
||||
tags:
|
||||
- customers
|
||||
operationId: listCustomers
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/currentUser'
|
||||
- $ref: '#/components/parameters/assumedRoles'
|
||||
- name: prefix
|
||||
in: query
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
description: Customer-prefix to filter the results.
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Customer'
|
||||
"401":
|
||||
description: Not Authorized
|
||||
"403":
|
||||
description: Forbidden
|
||||
post:
|
||||
summary: Adds a new customer.
|
||||
tags:
|
||||
- customers
|
||||
operationId: addCustomer
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/currentUser'
|
||||
- $ref: '#/components/parameters/assumedRoles'
|
||||
requestBody:
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/Customer'
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/Customer'
|
||||
|
||||
/api/rbac-users:
|
||||
get:
|
||||
tags:
|
||||
- rbacusers
|
||||
description: List accessible RBAC users with optional filter by name.
|
||||
operationId: listUsers
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/currentUser'
|
||||
- $ref: '#/components/parameters/assumedRoles'
|
||||
- name: name
|
||||
in: query
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/RbacUser'
|
||||
"401":
|
||||
description: if the 'current-user' cannot be identified
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/RbacUser'
|
||||
"403":
|
||||
description: if the 'current-user' is not allowed to assume any of the roles
|
||||
from 'assumed-roles'
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/RbacUser'
|
||||
|
||||
/api/rbac-users/{userName}/permissions:
|
||||
get:
|
||||
tags:
|
||||
- rbacusers
|
||||
description: 'List all visible permissions granted to the given user; reduced '
|
||||
operationId: listUserPermissions
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/currentUser'
|
||||
- $ref: '#/components/parameters/assumedRoles'
|
||||
- name: userName
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/RbacUserPermission'
|
||||
|
||||
"401":
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
"403":
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
|
||||
/api/rbac-roles:
|
||||
get:
|
||||
tags:
|
||||
- rbacroles
|
||||
operationId: listRoles
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/currentUser'
|
||||
- $ref: '#/components/parameters/assumedRoles'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/RbacRole'
|
||||
|
||||
/api/ping:
|
||||
get:
|
||||
tags:
|
||||
- test
|
||||
operationId: ping
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: string
|
||||
|
||||
/api/packages:
|
||||
get:
|
||||
tags:
|
||||
- packages
|
||||
operationId: listPackages
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/currentUser'
|
||||
- $ref: '#/components/parameters/assumedRoles'
|
||||
- name: name
|
||||
in: query
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Package'
|
||||
|
||||
components:
|
||||
|
||||
parameters:
|
||||
currentUser:
|
||||
name: current-user
|
||||
in: header
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: Identifying name of the currently logged in user.
|
||||
assumedRoles:
|
||||
name: assumed-roles
|
||||
in: header
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
description: Semicolon-separated list of roles to assume. The current user needs to have the right to assume these roles.
|
||||
|
||||
responses:
|
||||
NotFound:
|
||||
description: The specified was not found.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
Unauthorized:
|
||||
description: The current user is unknown or not authorized.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
Forbidden:
|
||||
description: The current user or none of the assumed or roles is granted access to the .
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
|
||||
schemas:
|
||||
Customer:
|
||||
type: object
|
||||
properties:
|
||||
uuid:
|
||||
type: string
|
||||
format: uuid
|
||||
prefix:
|
||||
type: string
|
||||
reference:
|
||||
type: integer
|
||||
format: int32
|
||||
adminUserName:
|
||||
type: string
|
||||
RbacUser:
|
||||
type: object
|
||||
properties:
|
||||
uuid:
|
||||
type: string
|
||||
format: uuid
|
||||
name:
|
||||
type: string
|
||||
RbacUserPermission:
|
||||
type: object
|
||||
properties:
|
||||
objectUuid:
|
||||
type: string
|
||||
format: uuid
|
||||
objectTable:
|
||||
type: string
|
||||
objectIdName:
|
||||
type: string
|
||||
roleName:
|
||||
type: string
|
||||
roleUuid:
|
||||
type: string
|
||||
format: uuid
|
||||
permissionUuid:
|
||||
type: string
|
||||
format: uuid
|
||||
op:
|
||||
type: string
|
||||
RbacRole:
|
||||
type: object
|
||||
properties:
|
||||
uuid:
|
||||
type: string
|
||||
format: uuid
|
||||
objectUuid:
|
||||
type: string
|
||||
format: uuid
|
||||
objectTable:
|
||||
type: string
|
||||
objectIdName:
|
||||
type: string
|
||||
roleType:
|
||||
type: string
|
||||
enum:
|
||||
- owner
|
||||
- admin
|
||||
- tenant
|
||||
roleName:
|
||||
type: string
|
||||
Package:
|
||||
type: object
|
||||
properties:
|
||||
uuid:
|
||||
type: string
|
||||
format: uuid
|
||||
name:
|
||||
type: string
|
||||
customer:
|
||||
$ref: '#/components/schemas/Customer'
|
||||
Error:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
required:
|
||||
- code
|
||||
- message
|
14
src/main/resources/api-mappings.yaml
Normal file
14
src/main/resources/api-mappings.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
openapi-processor-mapping: v2
|
||||
|
||||
options:
|
||||
package-name: net.hostsharing.hsadminng.generated.api.v1
|
||||
model-name-suffix: Resource
|
||||
|
||||
map:
|
||||
result: org.springframework.http.ResponseEntity
|
||||
|
||||
|
||||
types:
|
||||
- type: array => java.util.List
|
||||
- type: string:uuid => java.util.UUID
|
||||
|
Reference in New Issue
Block a user