1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-05-09 19:29:29 +08:00
Mainflux.mainflux/users/swagger.yaml
Ivan Milošević 0ab627730f MF-538 - Improve logging and API errors (#866)
* user service - wraping errors

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* wrapping more errors
unwrap only wrapped errors

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Add internal database error
Wrap internal database error

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Wrap user not found error

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Wrapping errors in idp and hasher

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Use error.Is for testing errors in Identify test

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Get wraper from wrapped errors

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Switch order of wrapping errors
Remove dead code (comments)

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* assert true in tests

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Change comparing errors in tests (assert.True)

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Add errorRes structure to API responses in body in things service

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* resolve conflicts after rebasing

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Create errors package

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* implement new errors package

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Modify tests

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* return copyright comments

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* remove changes from .gitignore

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Move logging to encode errors
Comment exported vars and methods
Formatting

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Login function returns errors.Error

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Modify login tests to meet login returning errors.Error

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Error interface

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Change parameter in Wrapper to interface Error

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* implement new error interface

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Modify tests to use new Error interface

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Fix Login

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Remove unnecessary errir casting

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* new error interface implementation

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* check if Error is empty in registrationEndpoint

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Add Empty factory function
Use new Empty factory function
Use isEmpty method

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Lose else in encodeError

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Modify tests

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Fix nil error value in jwtIdentityProvider

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Fix gprc to use new error package

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* rename receiver in errors package
grpc errors

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* remove debugging code

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Resolving conflicts after rebase

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Remove comment

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Remove Empty from custom error
Implement custom error on new methods

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* WIP tests

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* remove wrap from Error interface

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* password-change related tests
remove debug code

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* remove dead code

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Move all errors casting to errors package

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Fix comment in error package

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Change struct pointer to interface in package methods

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* resolving reviews

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* fix return in database.go

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Fix copyright header

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Fix comment in hasher

Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00

301 lines
8.0 KiB
YAML

swagger: "2.0"
info:
title: Mainflux users service
description: HTTP API for managing platform users.
version: "1.0.0"
consumes:
- "application/json"
produces:
- "application/json"
paths:
/users:
post:
summary: Registers user account
description: |
Registers new user account given email and password. New account will
be uniquely identified by its email address.
tags:
- users
parameters:
- name: user
description: JSON-formatted document describing the new user.
in: body
schema:
$ref: "#/definitions/User"
required: true
responses:
201:
description: Registered new user.
400:
description: Failed due to malformed JSON.
409:
description: Failed due to using an existing email address.
415:
description: Missing or invalid content type.
500:
$ref: "#/responses/ServiceError"
/users:
get:
summary: Gets info on currently logged in user.
description: |
Gets info on currently logged in user. Info is obtained using
authorization token
tags:
- users
parameters:
- $ref: "#/parameters/Authorization"
responses:
200:
description: Data retrieved.
schema:
$ref: "#/definitions/UsersPage"
400:
description: Failed due to malformed query parameters.
403:
description: Missing or invalid access token provided.
500:
$ref: "#/responses/ServiceError"
/users:
put:
summary: Updates info on currently logged in user.
description: |
Updates info on currently logged in user. Info is updated using
authorization token and the new received info.
tags:
- users
parameters:
- $ref: "#/parameters/Authorization"
- name: metadata
description: JSON-formatted document containing user info.
in: body
schema:
$ref: "#/definitions/CreateThingReq"
required: true
responses:
200:
description: User updated.
400:
description: Failed due to malformed JSON.
403:
description: Missing or invalid access token provided.
500:
$ref: "#/responses/ServiceError"
/tokens:
post:
summary: User authentication
description: |
Generates an access token when provided with proper credentials.
tags:
- users
parameters:
- name: credentials
description: JSON-formatted document containing user credentials.
in: body
schema:
$ref: "#/definitions/User"
required: true
responses:
201:
description: User authenticated.
schema:
$ref: "#/definitions/Token"
400:
description: |
Failed due to malformed JSON.
schema:
$ref: "#/definitions/Error"
403:
description: |
Failed due to using invalid credentials.
schema:
$ref: "#/definitions/Error"
415:
description: Missing or invalid content type.
schema:
$ref: "#/definitions/Error"
500:
$ref: "#/responses/ServiceError"
/password/reset-request:
post:
summary: User password reset request
description: |
Generates a reset token and sends and email with link for resetting password.
tags:
- users
parameters:
- name: email
description: JSON-formatted document containing user email.
in: body
schema:
$ref: "#/parameters/Authorization"
$ref: "#/definitions/PasswordResetRequest"
required: true
responses:
201:
description: User link .
400:
description: |
Failed due to malformed JSON.
415:
description: Missing or invalid content type.
500:
$ref: "#/responses/ServiceError"
/password/reset:
put:
summary: User password reset endpoint
description: |
When user gets reset token posting a new password along to this endpoint will change password.
tags:
- users
parameters:
- name: password
description: JSON-formatted document containing user email, token and new password.
in: body
schema:
$ref: "#/definitions/PasswordReset"
required: true
responses:
201:
description: User link .
400:
description: |
Failed due to malformed JSON.
415:
description: Missing or invalid content type.
500:
$ref: "#/responses/ServiceError"
/password:
patch:
summary: User password change endpoint
description: |
When authenticated user wants to change password.
tags:
- users
parameters:
- name: password
description: JSON-formatted document containing user email, token and new password.
in: body
schema:
$ref: "#/parameters/Authorization"
$ref: "#/definitions/PasswordChange"
required: true
responses:
201:
description: User link .
400:
description: |
Failed due to malformed JSON.
415:
description: Missing or invalid content type.
500:
$ref: "#/responses/ServiceError"
responses:
ServiceError:
description: Unexpected server-side error occurred.
definitions:
Token:
type: object
properties:
token:
type: string
description: Generated access token.
required:
- token
User:
type: object
properties:
email:
type: string
format: email
example: "test@example.com"
description: User's email address will be used as its unique identifier
password:
type: string
format: password
description: Free-form account password used for acquiring auth token(s).
required:
- email
- password
Email:
properties:
email:
type: string
format: email
example: "test@example.com"
description: User's email address will be used as its unique identifier
required:
- email
parameters:
Authorization:
name: Authorization
description: User's access token.
in: header
type: string
required: true
Referer:
name: Referer
description: Host being sent by browser.
in: header
type: string
required: true
Metadata:
name: metadata
description: Metadata filter. Filtering is performed matching the parameter with metadata on top level. Parameter is json.
in: query
type: string
minimum: 0
required: false
responses:
ServiceError:
description: Unexpected server-side error occurred.
definitions:
UsersPage:
type: object
properties:
email:
type: string
description: ID of the user
metadata:
type: object
description: Custom metadata related to User
updateUserReq:
type: object
description: Arbitrary, object-encoded user's data.
PasswordResetRequest:
type: object
properties:
email:
type: string
description: Email of the user
PasswordReset:
type: object
properties:
password:
type: string
description: New password
confirm_password:
type: string
description: New password confirmed
token:
type: string
description: Reset token generated and sent in email
PasswordChange:
type: object
properties:
password:
type: string
description: New password
old_password:
type: string
description: Confirm password
Error:
type: object
properties:
error:
type: string
description: Error message