Skip to content

Instantly share code, notes, and snippets.

@ok11
Created October 24, 2018 15:11
Show Gist options
  • Save ok11/6366b620192278b677cba169fc4c6db2 to your computer and use it in GitHub Desktop.
Save ok11/6366b620192278b677cba169fc4c6db2 to your computer and use it in GitHub Desktop.
go-swagger issue
type: object
properties:
value:
type: string
issuedAt:
type: string
format: datetime
signature:
type: string
required:
- value
- issuedAt
- signature
swagger: "2.0"
info:
description: >-
REST API for the User Management Service
version: "1"
title: "User Management"
termsOfService: "Experimental, no SLA"
contact:
email: "development@bbgo.org"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
# host: "localhost"
basePath: "/user-service/v1"
tags:
- name: User
description: "User"
- name: Token
description: "Token"
schemes:
- "https"
- "http"
paths:
/users:
post:
tags:
- User
summary: "an operation to register a new user"
description: >-
Registers a new user
operationId: "registerUser"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: payload
in: body
description: >-
Data for the user to be registered
schema:
$ref: "./Data.yaml"
required: true
responses:
201:
description: Created
headers:
Location:
description: URI of the registered resource
type: string
#format: uri
ETag:
description: >-
Fingerprint of the created resource
type: string
schema:
$ref: "./User.yaml"
400:
$ref: "./responses.yaml#/400"
401:
$ref: "./responses.yaml#/401"
403:
$ref: "./responses.yaml#/403"
500:
$ref: "./responses.yaml#/500"
get:
tags:
- User
summary: Get all users
description: >-
Get all users
operationId: "getUsers"
produces:
- "application/json"
parameters:
- $ref: "./parameters.yaml#/filter"
- $ref: "./parameters.yaml#/top"
- $ref: "./parameters.yaml#/skip"
- $ref: "./parameters.yaml#/search"
responses:
200:
description: OK
schema:
$ref: "./Users.yaml"
400:
$ref: "./responses.yaml#/400"
401:
$ref: "./responses.yaml#/401"
403:
$ref: "./responses.yaml#/403"
404:
$ref: "./responses.yaml#/404"
500:
$ref: "./responses.yaml#/500"
security:
- tokenAuth: [ADMIN, USER]
/users/{id}:
get:
tags:
- User
summary: "Retrieve a user by ID"
description: >-
Returns user
operationId: "getUser"
produces:
- "application/json"
parameters:
- in: path
name: "id"
description: "User ID"
type: string
required: true
responses:
200:
description: OK
headers:
ETag:
description: >-
Fingerprint of the user object retrieved
type: string
schema:
$ref: "./User.yaml"
400:
$ref: "./responses.yaml#/400"
401:
$ref: "./responses.yaml#/401"
403:
$ref: "./responses.yaml#/403"
404:
$ref: "./responses.yaml#/404"
500:
$ref: "./responses.yaml#/500"
security:
- tokenAuth: [ADMIN, USER]
delete:
tags:
- User
summary: Deletes a user
description: >-
Deletes a user
operationId: deleteUser
parameters:
- name: id
in: path
description: ID of a user to delete
required: true
type: "string"
responses:
204:
$ref: "./responses.yaml#/204"
400:
$ref: "./responses.yaml#/400"
401:
$ref: "./responses.yaml#/401"
403:
$ref: "./responses.yaml#/403"
404:
$ref: "./responses.yaml#/404"
500:
$ref: "./responses.yaml#/500"
security:
- tokenAuth: [ADMIN, USER]
/users/{id}/data:
put:
tags:
- User
summary: Update an existing user data
description: >-
Updates data for an existing user
operationId: updateData
consumes:
- application/json
produces:
- application/json
parameters:
- in: path
name: id
description: ID of the user to update
type: string
required: true
- in: body
name: payload
description: User data to be updated
required: true
schema:
$ref: "./Data.yaml"
- $ref: "./parameters.yaml#/ifmatch"
responses:
200:
description: OK
headers:
ETag:
description: "Fingerprint of the user object updated"
type: string
schema:
$ref: "./User.yaml"
400:
$ref: "./responses.yaml#/400"
401:
$ref: "./responses.yaml#/401"
403:
$ref: "./responses.yaml#/403"
404:
$ref: "./responses.yaml#/404"
412:
$ref: "./responses.yaml#/412"
500:
$ref: "./responses.yaml#/500"
security:
- tokenAuth: [ADMIN, USER]
/users/{id}/roles:
put:
tags:
- User
summary: Update roles for an existing user
description: >-
Updates roles for an existing user
operationId: updateRoles
consumes:
- application/json
produces:
- application/json
parameters:
- in: path
name: id
description: ID of the user to update
type: string
required: true
- in: body
name: payload
description: User roles to be updated
required: true
schema:
$ref: "./Roles.yaml"
- $ref: "./parameters.yaml#/ifmatch"
responses:
200:
description: OK
headers:
ETag:
description: "Fingerprint of the user object updated"
type: string
schema:
$ref: "./User.yaml"
400:
$ref: "./responses.yaml#/400"
401:
$ref: "./responses.yaml#/401"
403:
$ref: "./responses.yaml#/403"
404:
$ref: "./responses.yaml#/404"
412:
$ref: "./responses.yaml#/412"
500:
$ref: "./responses.yaml#/500"
security:
- tokenAuth: [ADMIN, USER]
/token:
post:
tags:
- Token
summary: Issues a token for an authenticated user
description: >-
Issues a token for an authenticated user
operationId: issueToken
produces:
- application/json
responses:
200:
description: OK
schema:
$ref: "./AccessToken.yaml"
400:
$ref: "./responses.yaml#/400"
401:
$ref: "./responses.yaml#/401"
403:
$ref: "./responses.yaml#/403"
404:
$ref: "./responses.yaml#/404"
412:
$ref: "./responses.yaml#/412"
500:
$ref: "./responses.yaml#/500"
security:
- basicAuth: []
securityDefinitions:
basicAuth:
type: basic
tokenAuth:
type: apiKey
in: header
name: Authorization
# User
type: object
properties:
username:
type: string
example: "Testuser"
description: "A username of the user"
password:
type: string
example: "123Test!"
description: "A password of the user"
required:
- username
- password
# Data
type: object
properties:
name:
type: string
example: "Test User"
description: "A name of the user"
credentials:
$ref: "./Credentials.yaml"
required:
- credentials
# Error
type: object
properties:
code:
type: string
description: "Error code"
example: RESOURCE_NOT_FOUND
message:
type: string
description: "Error message"
example: "Requested resource not found"
target:
type: string
description: "Related resource"
example: "/products/42"
details:
type: object
properties:
code:
type: string
description: "Detailed error code"
example: "MongoDB:2038"
message:
type: string
description: "Detailed error message"
example: "MongoDB: no document with ObjectID 42"
required:
- code
- message
required:
- code
- message
top:
name: $top
in: query
description: >-
Show only the first N elements, where N is a positive integer. If a value
less than 0 is specified, the URI should be considered malformed.
type: integer
minimum: 0
required: false
skip:
name: $skip
in: query
description: >-
Skip the first N elements, where N is a positive integer as specified by
this query option. If a value less than 0 is specified, the URI should be
considered malformed.
type: integer
minimum: 0
required: false
search:
name: $search
in: query
description: Free text search on selected entity.
type: string
required: false
filter:
name: $filter
in: query
description: >-
Causes returning only entities, for those the filter condition evaluates true.
type: string
required: false
etag:
name: ETag
in: header
description: Known fingerprint of the entity
type: string
required: false
ifmatch:
name: If-Match
in: header
description: >-
The request will succeed if the value equals to the current fingerprint
of the entity on the server side.
type: string
required: false
204:
description: No Content
400:
description: Bad Request
schema:
$ref: './Error.yaml'
examples:
application/json:
code: MISSING_PARAMETERS
message: >-
Required parameters missing or incorrect.
401:
description: Unauthorized
headers:
WWW_Authenticate:
type: string
schema:
$ref: './Error.yaml'
examples:
application/json:
code: UNAUTHORIZED
message: >-
To access API you have to login
403:
description: Forbidden
schema:
$ref: './Error.yaml'
examples:
application/json:
code: FORBIDDEN
message: >-
Insufficient privileges to access API
404:
description: Not Found
schema:
$ref: './Error.yaml'
examples:
application/json:
code: RESOURCE_NOT_FOUND
message: >-
Requested resource not found
412:
description: Precondition Failed
schema:
$ref: "./Error.yaml"
examples:
application/json:
code: CONCURRENT_MODIFICATION
message: >-
The resource was modified in the meanwhile
500:
description: Internal server error
schema:
$ref: './Error.yaml'
examples:
application/json:
code: INTERNAL_SERVER_ERROR
message: >-
Internal server error occurred, retry after some time. In case the issue
persists contact your system administrator
501:
description: Not Implemented
schema:
$ref: './Error.yaml'
examples:
application/json:
code: FEATURE_NOT_IMPLEMENTED
message: Requested feature is not implemented.
# Roles
type: array
items:
type: string
enum:
- ADMIN
- USER
example: "User"
description: "A role of the user"
# User
type: object
properties:
id:
type: string
format: uuid
readOnly: true
example: "87dcb276-d495-11e8-b06f-54ee75efd688"
description: "An ID of the user"
data:
$ref: "./Data.yaml"
roles:
$ref: "./Roles.yaml"
required:
- data
# Users
type: object
properties:
users:
type: array
items:
$ref: "./User.yaml"
required:
- users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment