From 6fb1a7aa8fc9adac4d10c58009184c976d5ff19f Mon Sep 17 00:00:00 2001 From: Anatoliy Sablin Date: Fri, 7 Dec 2018 22:32:26 +0300 Subject: [PATCH 1/9] Swagger schema stub. --- api.yaml | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 api.yaml diff --git a/api.yaml b/api.yaml new file mode 100644 index 0000000..693bd15 --- /dev/null +++ b/api.yaml @@ -0,0 +1,92 @@ +openapi: 3.0.1 +info: + title: www.jabber.ru api + description: www.jabber.ru backend api. + version: 0.1.0-SNAPSHOT +servers: + - url: www.jabber.ru +paths: + /json/articles: + get: + summary: get articles + description: news! + operationId: get_articles + parameters: + responses: + '200': + description: news + content: + application/json: + schema: + $ref: '#/definitions/Articles' + /json/auth: + post: + summary: login + description: login + operationId: post_login + requestBody: + description: user credentials + required: true + content: + application/json: + schema: + $ref: '#/definitions/Auth' + responses: + '200': + description: logged + /json/logout: + /json/domains: + /json/register: + /json/reset: + /json/vcard: + /json/setemail: + /json/roster: + /json/feedback: + /json/mam/settings: + /json/mam/messages: +definitions: + Auth: + required: + - login + - password + - captcha + properties: + login: + type: string + password: + type: string + captcha: + type: string + Articles: + type: object + properties: + articles: + type: array + items: + $ref: '#/definitions/Article' + Article: + type: object + properties: + id: + type: string + author: + type: string + title: + type: string + body: + type: string + posted: + type: string + format: date-time + modified: + type: string + format: date-time + published: + type: string + format: date-time + tags: + type: array + items: + type: string + alias: + type: string From 70f3063e184eb9468529a4c93d7a71f1477889e2 Mon Sep 17 00:00:00 2001 From: Anatoliy Sablin Date: Fri, 7 Dec 2018 23:02:38 +0300 Subject: [PATCH 2/9] Fix openapi schema. --- api.yaml | 180 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 124 insertions(+), 56 deletions(-) diff --git a/api.yaml b/api.yaml index 693bd15..ed07953 100644 --- a/api.yaml +++ b/api.yaml @@ -11,14 +11,13 @@ paths: summary: get articles description: news! operationId: get_articles - parameters: responses: '200': description: news content: application/json: schema: - $ref: '#/definitions/Articles' + $ref: '#/components/schemas/Articles' /json/auth: post: summary: login @@ -30,63 +29,132 @@ paths: content: application/json: schema: - $ref: '#/definitions/Auth' + $ref: '#/components/schemas/Auth' responses: '200': description: logged /json/logout: + get: + summary: logout + description: invalidate credentials + operationId: get_logout + responses: + '200': + description: logouted /json/domains: + get: + summary: get domains + description: domains... + operationId: get_domains + responses: + '200': + description: domains + content: + application/json: + schema: + $ref: '#/components/schemas/DomainList' /json/register: - /json/reset: - /json/vcard: - /json/setemail: - /json/roster: - /json/feedback: - /json/mam/settings: - /json/mam/messages: -definitions: - Auth: - required: - - login - - password - - captcha - properties: - login: - type: string - password: - type: string - captcha: - type: string - Articles: - type: object - properties: - articles: - type: array - items: - $ref: '#/definitions/Article' - Article: - type: object - properties: - id: - type: string - author: - type: string - title: - type: string - body: - type: string - posted: - type: string - format: date-time - modified: - type: string - format: date-time - published: - type: string - format: date-time - tags: - type: array - items: - type: string - alias: - type: string + post: + summary: register + description: register a new account + operationId: post_register + requestBody: + description: register data + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Register' + responses: + '200': + description: registered +# /json/reset: +# /json/vcard: +# /json/setemail: +# /json/roster: +# /json/feedback: +# /json/mam/settings: +# /json/mam/messages: +components: + schemas: + Register: + required: + - captcha + - login + - password + - email + - hash + properties: + captcha: + type: string + login: + type: string + password: + type: string + email: + type: string + phone: + type: string + hash: + type: string + ErrorResult: + properties: + result: + type: string + error: + type: string + Domains: + properties: + domains: + type: array + items: + type: string + DomainList: + oneOf: + - $ref: '#/components/schemas/ErrorResult' + - $ref: '#/components/schemas/Domains' + Auth: + required: + - login + - password + - captcha + properties: + login: + type: string + password: + type: string + captcha: + type: string + Articles: + type: object + properties: + articles: + type: array + items: + $ref: '#/components/schemas/Article' + Article: + type: object + properties: + id: + type: string + author: + type: string + title: + type: string + body: + type: string + posted: + type: string + format: date-time + modified: + type: string + format: date-time + published: + type: string + format: date-time + tags: + type: array + items: + type: string + alias: + type: string From f94605d15ac973167018cdcc301f6d0df0681d6d Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Mon, 10 Dec 2018 23:02:02 +0300 Subject: [PATCH 3/9] Rest apis --- api.yaml | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 210 insertions(+), 12 deletions(-) diff --git a/api.yaml b/api.yaml index ed07953..2957c6a 100644 --- a/api.yaml +++ b/api.yaml @@ -6,7 +6,7 @@ info: servers: - url: www.jabber.ru paths: - /json/articles: + /api/v2/json/articles: get: summary: get articles description: news! @@ -18,7 +18,7 @@ paths: application/json: schema: $ref: '#/components/schemas/Articles' - /json/auth: + /api/v2/json/auth: post: summary: login description: login @@ -33,7 +33,7 @@ paths: responses: '200': description: logged - /json/logout: + /api/v2/json/logout: get: summary: logout description: invalidate credentials @@ -41,7 +41,7 @@ paths: responses: '200': description: logouted - /json/domains: + /api/v2/json/domains: get: summary: get domains description: domains... @@ -53,7 +53,7 @@ paths: application/json: schema: $ref: '#/components/schemas/DomainList' - /json/register: + /api/v2/json/register: post: summary: register description: register a new account @@ -68,15 +68,213 @@ paths: responses: '200': description: registered -# /json/reset: -# /json/vcard: -# /json/setemail: -# /json/roster: -# /json/feedback: -# /json/mam/settings: -# /json/mam/messages: + /api/v2/json/reset: + post: + summary: reset password + description: sent an email message with the link to reset password + operationId: post_reset + requestBody: + description: reset request body + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Register' + responses: + '200': + description: reset + /api/v2/json/vcard: + get: + summary: get user vcard + description: get user vcard + operationId: get_vcard + responses: + '200': + description: users info + content: + application/json: + schema: + $ref: '#/components/schemas/VCardResponse' + /api/v2/json/setemail: + post: + summary: set an email + description: link jid with the email + operationId: post_setemail + requestBody: + description: set email request body + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Register' + responses: + '200': + description: email was setup + /api/v2/json/roster: + get: + summary: get the roster + description: retrieve user roster + operationId: get_roster + responses: + '200': + description: roster + content: + application/json: + schema: + $ref: '#/components/schemas/RosterListResponse' + /api/v2/json/feedback: + post: + summary: sent a feedback + description: sent a message to site admins + operationId: post_feedback + requestBody: + description: request body + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Feedback' + responses: + '200': + description: the message was sent + /api/v2/json/mam/settings: + get: + summary: get MAM settings + description: get MAM settings + operationId: get_settings + responses: + '200': + description: MAM settings + content: + application/json: + schema: + $ref: '#/components/schemas/MAMSettingsResponse' + post: + summary: set MAM settings + description: set MAM settings + operationId: post_settings + requestBody: + description: request body + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/MAMSettings' + responses: + '200': + description: settings were updated + /api/v2/json/mam/messages: + post: + summary: get mam messages + description: get mam messages from the specified jid + operationId: post_messages + requestBody: + description: message owner + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/MAMMessageRequest' + responses: + '200': + description: messages + content: + application/json: + schema: + $ref: '#/components/schemas/MAMMessageListResponse' components: schemas: + MAMMessageListResponse: + oneOf: + - $ref: '#/components/schemas/ErrorResult' + - $ref: '#/components/schemas/MAMMessageList' + MAMMessageList: + properties: + messages: + type: array + items: + $ref: '#/components/schemas/MAMMessage' + MAMMessage: + properties: + ts: + type: integer + format: int64 + bare_peer: + type: string + id: + type: string + kind: + type: string + nick: + type: string + txt: + type: string + xml: + type: string + direction: + type: string + MAMMessageRequest: + required: + - jid + properties: + jid: + type: string + ts: + type: integer + format: int64 + MAMSettingsResponse: + oneOf: + - $ref: '#/components/schemas/ErrorResult' + - $ref: '#/components/schemas/MAMSettings' + MAMSettings: + properties: + default: + type: string + always: + type: array + items: + type: string + never: + type: array + items: + type: string + created_at: + type: string + format: date-time + Feedback: + properties: + email: + type: string + message: + type: string + captcha: + type: string + RosterListResponse: + oneOf: + - $ref: '#/components/schemas/ErrorResult' + - $ref: '#/components/schemas/RosterList' + RosterList: + properties: + roster: + type: array + items: + $ref: '#/components/schemas/Roster' + Roster: + properties: + jid: + type: string + name: + type: string + VCardResponse: + oneOf: + - $ref: '#/components/schemas/ErrorResult' + - $ref: '#/components/schemas/VCard' + VCard: + properties: + nickname: + type: string + fullName: + type: string Register: required: - captcha From 6a141fc23e27215ea800fc7d2ebe6c34321c54de Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Wed, 12 Dec 2018 22:07:38 +0300 Subject: [PATCH 4/9] Fix mistakes. --- api.yaml | 72 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/api.yaml b/api.yaml index 2957c6a..9cb3445 100644 --- a/api.yaml +++ b/api.yaml @@ -2,7 +2,7 @@ openapi: 3.0.1 info: title: www.jabber.ru api description: www.jabber.ru backend api. - version: 0.1.0-SNAPSHOT + version: v2 servers: - url: www.jabber.ru paths: @@ -17,7 +17,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Articles' + $ref: '#/components/schemas/ArticlesResponse' /api/v2/json/auth: post: summary: login @@ -29,10 +29,14 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Auth' + $ref: '#/components/schemas/AuthResponse' responses: '200': description: logged + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResult' /api/v2/json/logout: get: summary: logout @@ -41,6 +45,10 @@ paths: responses: '200': description: logouted + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResult' /api/v2/json/domains: get: summary: get domains @@ -68,6 +76,10 @@ paths: responses: '200': description: registered + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResult' /api/v2/json/reset: post: summary: reset password @@ -83,6 +95,10 @@ paths: responses: '200': description: reset + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResult' /api/v2/json/vcard: get: summary: get user vcard @@ -110,6 +126,10 @@ paths: responses: '200': description: email was setup + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResult' /api/v2/json/roster: get: summary: get the roster @@ -137,6 +157,10 @@ paths: responses: '200': description: the message was sent + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResult' /api/v2/json/mam/settings: get: summary: get MAM settings @@ -163,6 +187,10 @@ paths: responses: '200': description: settings were updated + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResult' /api/v2/json/mam/messages: post: summary: get mam messages @@ -185,7 +213,7 @@ paths: components: schemas: MAMMessageListResponse: - oneOf: + allOf: - $ref: '#/components/schemas/ErrorResult' - $ref: '#/components/schemas/MAMMessageList' MAMMessageList: @@ -223,7 +251,7 @@ components: type: integer format: int64 MAMSettingsResponse: - oneOf: + allOf: - $ref: '#/components/schemas/ErrorResult' - $ref: '#/components/schemas/MAMSettings' MAMSettings: @@ -250,7 +278,7 @@ components: captcha: type: string RosterListResponse: - oneOf: + allOf: - $ref: '#/components/schemas/ErrorResult' - $ref: '#/components/schemas/RosterList' RosterList: @@ -266,7 +294,7 @@ components: name: type: string VCardResponse: - oneOf: + allOf: - $ref: '#/components/schemas/ErrorResult' - $ref: '#/components/schemas/VCard' VCard: @@ -276,23 +304,33 @@ components: fullName: type: string Register: + oneOf: + - $ref: '#/components/schemas/RegisterEmail' + - $ref: '#/components/schemas/RegisterPassword' + RegisterEmail: required: - - captcha - login - - password - email - - hash + - captcha properties: captcha: type: string login: type: string - password: - type: string email: type: string phone: type: string + RegisterPassword: + required: + - login + - password + - hash + properties: + login: + type: string + password: + type: string hash: type: string ErrorResult: @@ -308,9 +346,13 @@ components: items: type: string DomainList: - oneOf: + allOf: - $ref: '#/components/schemas/ErrorResult' - $ref: '#/components/schemas/Domains' + AuthResponse: + allOf: + - $ref: '#/components/schemas/ErrorResult' + - $ref: '#/components/schemas/Auth' Auth: required: - login @@ -323,6 +365,10 @@ components: type: string captcha: type: string + ArticlesResponse: + allOf: + - $ref: '#/components/schemas/ErrorResult' + - $ref: '#/components/schemas/Articles' Articles: type: object properties: From 58be4d4c7980693722ab5265872221b8270bc56e Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Thu, 13 Dec 2018 22:44:12 +0300 Subject: [PATCH 5/9] One more fixes. --- api.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/api.yaml b/api.yaml index 9cb3445..e7e0064 100644 --- a/api.yaml +++ b/api.yaml @@ -29,7 +29,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/AuthResponse' + $ref: '#/components/schemas/Auth' responses: '200': description: logged @@ -349,10 +349,6 @@ components: allOf: - $ref: '#/components/schemas/ErrorResult' - $ref: '#/components/schemas/Domains' - AuthResponse: - allOf: - - $ref: '#/components/schemas/ErrorResult' - - $ref: '#/components/schemas/Auth' Auth: required: - login From 0364cd8649ff3c3a418b435a64552cc4000f90d7 Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Fri, 14 Dec 2018 23:00:38 +0300 Subject: [PATCH 6/9] Fix version. --- api.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.yaml b/api.yaml index e7e0064..ff5cb8d 100644 --- a/api.yaml +++ b/api.yaml @@ -2,7 +2,7 @@ openapi: 3.0.1 info: title: www.jabber.ru api description: www.jabber.ru backend api. - version: v2 + version: v1 servers: - url: www.jabber.ru paths: @@ -286,7 +286,7 @@ components: roster: type: array items: - $ref: '#/components/schemas/Roster' + $ref: '#/components/schemas/Roster' Roster: properties: jid: From c34171e5400e412ac3d906f2520b4298db97d4ce Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Fri, 14 Dec 2018 23:10:18 +0300 Subject: [PATCH 7/9] Move swagger schemas to the special folder. --- api.yaml => swagger/v1.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename api.yaml => swagger/v1.yaml (100%) diff --git a/api.yaml b/swagger/v1.yaml similarity index 100% rename from api.yaml rename to swagger/v1.yaml From efdb8840188e205e4df3f3c26c34ea6d7a00a0c3 Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Fri, 14 Dec 2018 23:11:10 +0300 Subject: [PATCH 8/9] Fix vcard. --- swagger/v1.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/swagger/v1.yaml b/swagger/v1.yaml index ff5cb8d..264556c 100644 --- a/swagger/v1.yaml +++ b/swagger/v1.yaml @@ -299,10 +299,10 @@ components: - $ref: '#/components/schemas/VCard' VCard: properties: - nickname: - type: string - fullName: + jid: type: string + vcard: + type: object Register: oneOf: - $ref: '#/components/schemas/RegisterEmail' From f3ff79600dd6c2d1e217cd24c1344f482a08333d Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Wed, 26 Dec 2018 21:30:27 +0300 Subject: [PATCH 9/9] Schema wasn't changed. --- swagger/{v1.yaml => v2.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename swagger/{v1.yaml => v2.yaml} (100%) diff --git a/swagger/v1.yaml b/swagger/v2.yaml similarity index 100% rename from swagger/v1.yaml rename to swagger/v2.yaml