From 6924473f78ea3c0790f4d5beb49e35d0e596add3 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Tue, 3 Dec 2019 21:30:47 +0100 Subject: [PATCH 1/2] users swagger def --- docs/resources-manager.yml | 215 ++++++++++++++++++++++++++----------- 1 file changed, 150 insertions(+), 65 deletions(-) diff --git a/docs/resources-manager.yml b/docs/resources-manager.yml index 592d59f..63adc89 100644 --- a/docs/resources-manager.yml +++ b/docs/resources-manager.yml @@ -1,110 +1,195 @@ swagger: "2.0" info: - description: "SimplePAD API" + description: "Resources Manager API" version: "1.0.0" title: "SimplePad API" -host: "simplepad.localhost" +host: "localhost" basePath: "/api" tags: -- name: "pad" - description: "CRUD Pads" +- name: "user" + description: "Operations about user" schemes: - "https" - "http" paths: - /pad: + /user: post: tags: - - "pad" - summary: "Create a new pad" - description: "Create a new PAD (with a random id)" - consumes: + - "user" + summary: "Create user" + description: "Need pass an api key to authentificate." + operationId: "createUser" + produces: - "application/json" + parameters: + - in: "body" + name: "body" + description: "Created user object" + required: true + schema: + $ref: "#/definitions/User" + - in: header + name: X-API-Key + type: string + required: true + responses: + default: + description: "successful operation" + /user/createWithArray: + post: + tags: + - "user" + summary: "Creates list of users with given input array" + description: "" + operationId: "createUsersWithArrayInput" produces: + - "application/xml" - "application/json" parameters: - in: "body" name: "body" + description: "List of user object" required: true schema: - $ref: "#/definitions/Pad" + type: "array" + items: + $ref: "#/definitions/User" + - in: header + name: X-API-Key + type: string + required: true responses: - 405: - description: "Invalid input" - 200: - description: "SuccessFull" - schema: - $ref: "#/definitions/Pad" - - /pad/{pad_id}: + default: + description: "successful operation" + /user/createWithList: + post: + tags: + - "user" + summary: "Creates list of users with given input array" + description: "" + operationId: "createUsersWithListInput" + produces: + - "application/xml" + - "application/json" + parameters: + - in: "body" + name: "body" + description: "List of user object" + required: true + schema: + type: "array" + items: + $ref: "#/definitions/User" + - in: header + name: X-API-Key + type: string + required: true + responses: + default: + description: "successful operation" + /user/{username}: get: tags: - - "pad" + - "user" + summary: "Get user by user name" + description: "" + operationId: "getUserByName" produces: + - "application/xml" - "application/json" parameters: - - in: "path" - name: "pad_id" + - name: "username" + in: "path" + description: "The name that needs to be fetched." required: true + type: "string" + - in: header + name: X-API-Key type: string - maxLength: 6 - minLength: 6 + required: false responses: - 404: - description: "Does not exists" 200: - description: "SuccessFull" + description: "successful operation" schema: - $ref: "#/definitions/Pad" - post: + $ref: "#/definitions/User" + 400: + description: "Invalid username supplied" + 404: + description: "User not found" + put: tags: - - "pad" - description: "Create a new PAD with the given ID" + - "user" + summary: "Updated user" + description: "This can only be done by the logged in user." + operationId: "updateUser" produces: + - "application/xml" - "application/json" parameters: - - in: "path" - name: "pad_id" + - name: "username" + in: "path" + description: "name that need to be updated" required: true - type: string - maxLength: 6 - minLength: 6 + type: "string" - in: "body" name: "body" - description: "content" + description: "Updated user object" required: true schema: - $ref: "#/definitions/PadPost" + $ref: "#/definitions/User" + - in: header + name: X-API-Key + type: string + required: true responses: - 405: - description: "Invalid input" - 409: - description: "Given Id already exists" - 200: - description: "SuccessFull" - schema: - $ref: "#/definitions/Pad" - + 400: + description: "Invalid user supplied" + 404: + description: "User not found" + delete: + tags: + - "user" + summary: "Delete user" + description: "This can only be done by the logged in user." + operationId: "deleteUser" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "username" + in: "path" + description: "The name that needs to be deleted" + required: true + type: "string" + - in: header + name: X-API-Key + type: string + required: true + responses: + 400: + description: "Invalid username supplied" + 404: + description: "User not found" definitions: - Pad: + User: type: "object" properties: id: - type: string - maxLength: 6 - minLength: 6 - content: - type: string - create_date: - type: string - format: date - PadPost: - type: "object" - required: - - content - properties: - content: - type: string - - - + type: "integer" + format: "int64" + username: + type: "string" + firstName: + type: "string" + lastName: + type: "string" + email: + type: "string" + password: + type: "string" + phone: + type: "string" + userStatus: + type: "integer" + format: "int32" + description: "User Status" \ No newline at end of file From ba73c88df9a1e6b6de0208e5e3422828d0356a02 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Tue, 3 Dec 2019 22:20:51 +0100 Subject: [PATCH 2/2] sessions swagger defs --- docs/resources-manager.yml | 149 ++++++++++++++++++++++++++++--------- 1 file changed, 112 insertions(+), 37 deletions(-) diff --git a/docs/resources-manager.yml b/docs/resources-manager.yml index 63adc89..9f835d9 100644 --- a/docs/resources-manager.yml +++ b/docs/resources-manager.yml @@ -8,9 +8,10 @@ basePath: "/api" tags: - name: "user" description: "Operations about user" +- name: "session" + description: "logon and log out methods to get a token" schemes: - "https" -- "http" paths: /user: post: @@ -18,7 +19,6 @@ paths: - "user" summary: "Create user" description: "Need pass an api key to authentificate." - operationId: "createUser" produces: - "application/json" parameters: @@ -35,41 +35,17 @@ paths: responses: default: description: "successful operation" - /user/createWithArray: - post: - tags: - - "user" - summary: "Creates list of users with given input array" - description: "" - operationId: "createUsersWithArrayInput" - produces: - - "application/xml" - - "application/json" - parameters: - - in: "body" - name: "body" - description: "List of user object" - required: true - schema: - type: "array" - items: - $ref: "#/definitions/User" - - in: header - name: X-API-Key - type: string - required: true - responses: - default: - description: "successful operation" + 401: + description: Authentification failed + 403: + description: You are not allowed to do that /user/createWithList: post: tags: - "user" summary: "Creates list of users with given input array" description: "" - operationId: "createUsersWithListInput" produces: - - "application/xml" - "application/json" parameters: - in: "body" @@ -87,15 +63,17 @@ paths: responses: default: description: "successful operation" + 401: + description: Authentification failed + 403: + description: You are not allowed to do that /user/{username}: get: tags: - "user" summary: "Get user by user name" description: "" - operationId: "getUserByName" produces: - - "application/xml" - "application/json" parameters: - name: "username" @@ -111,19 +89,21 @@ paths: 200: description: "successful operation" schema: - $ref: "#/definitions/User" + $ref: "#/definitions/UserInfo" 400: description: "Invalid username supplied" 404: description: "User not found" + 401: + description: Authentification failed + 403: + description: You are not allowed to do that put: tags: - "user" summary: "Updated user" description: "This can only be done by the logged in user." - operationId: "updateUser" produces: - - "application/xml" - "application/json" parameters: - name: "username" @@ -146,6 +126,10 @@ paths: description: "Invalid user supplied" 404: description: "User not found" + 401: + description: Authentification failed + 403: + description: You are not allowed to do that delete: tags: - "user" @@ -153,7 +137,6 @@ paths: description: "This can only be done by the logged in user." operationId: "deleteUser" produces: - - "application/xml" - "application/json" parameters: - name: "username" @@ -170,6 +153,47 @@ paths: description: "Invalid username supplied" 404: description: "User not found" + 401: + description: Authentification failed + 403: + description: You are not allowed to do that + /session: + get: + tags: + - session + summary: "Get current session info" + parameters: + - in: header + name: X-API-Key + type: string + required: true + responses: + 401: + description: Authentification failed + 200: + description: "successful operation" + schema: + $ref: "#/definitions/Session" + post: + tags: + - session + summary: "Try to auth and retrive an api key" + parameters: + - in: "body" + name: "body" + description: "auth" + required: true + schema: + $ref: "#/definitions/InternalAuth" + responses: + 401: + description: Authentification failed + 200: + description: "successful operation" + schema: + $ref: "#/definitions/Session" + + definitions: User: type: "object" @@ -187,9 +211,60 @@ definitions: type: "string" password: type: "string" + format: "password" phone: type: "string" userStatus: type: "integer" format: "int32" - description: "User Status" \ No newline at end of file + description: "User Status" + authMethod: + type: "string" + pattern: '^(internal|ldap|cas)$' + UserInfo: + type: "object" + properties: + id: + type: "integer" + format: "int64" + username: + type: "string" + firstName: + type: "string" + lastName: + type: "string" + email: + type: "string" + phone: + type: "string" + userStatus: + type: "integer" + format: "int32" + description: "User Status" + authMethod: + type: "string" + pattern: '^(internal|ldap|cas)$' + lastConnect: + type: "string" + format: date-time + Session: + type: "object" + properties: + user: + type: object + createDate: + type: string + format: date-time + endDate: + type: string + format: date-time + X-API-Key: + type: string + InternalAuth: + type: "object" + properties: + username: + type: "string" + password: + type: "string" + format: password \ No newline at end of file