From 08b392e94e57bd633990b3d3878cfa448f425248 Mon Sep 17 00:00:00 2001 From: keenthinker <1250439+keenthinker@users.noreply.github.com> Date: Mon, 26 Oct 2020 22:49:04 +0100 Subject: [PATCH] update API definitions --- api/random.js | 3 - apidefinition.json | 432 ++++++++++++++++++++++++++------------------- apidefinition.yaml | 45 +++++ 3 files changed, 292 insertions(+), 188 deletions(-) diff --git a/api/random.js b/api/random.js index 96ca3ad..dcd87e6 100644 --- a/api/random.js +++ b/api/random.js @@ -113,9 +113,6 @@ module.exports = (req, res) => { let min = 1; let max = 1048576; let resultsCount = 1; - // TODO: noDuplicates needs additional validation when "true" - // - results count and range should be "compatible", f.e. min=1,max=10, count=25 is not possible - // - distribution/speed - count and max? let noDuplicates = false; let sort = false; diff --git a/apidefinition.json b/apidefinition.json index 2346955..7f81f72 100644 --- a/apidefinition.json +++ b/apidefinition.json @@ -1,198 +1,260 @@ { - "swagger": "2.0", - "info": { - "description": "This is the description of the hipstapas API. You can find out more at [https://hipstapas.dev](https://hipstapas.dev). You can find the documentation at [https://hipstapas.dev/docs](https://hipstapas.dev/docs).", - "version": "1.0.0", - "title": "hipstapas.dev", - "termsOfService": "https://hipstapas.dev/privacy", - "contact": { - "email": "hello@hipstapas.dev" - }, - "license": { - "name": "MIT", - "url": "https://github.com/keenthinker/hipstapas/blob/master/LICENSE" + "swagger": "2.0", + "info": { + "description": "This is the description of the hipstapas API. You can find out more at [https://hipstapas.dev](https://hipstapas.dev). You can find the documentation at [https://hipstapas.dev/docs](https://hipstapas.dev/docs).", + "version": "1.0.0", + "title": "hipstapas.dev", + "termsOfService": "https://hipstapas.dev/privacy", + "contact": { + "email": "hello@hipstapas.dev" + }, + "license": { + "name": "MIT", + "url": "https://github.com/keenthinker/hipstapas/blob/master/LICENSE" + } + }, + "host": "hipstapas.dev", + "basePath": "/api", + "tags": [ + { + "name": "index", + "description": "Generate strong phrases (passwords)", + "externalDocs": { + "description": "Find out more", + "url": "https://hipstapas.dev/docs" } }, - "host": "hipstapas.dev", - "basePath": "/api", - "tags": [ - { - "name": "index", - "description": "Generate strong phrases (passwords)", - "externalDocs": { - "description": "Find out more", - "url": "https://hipstapas.dev/docs" - } - }, - { - "name": "uuid", - "description": "Generate UUID's / GUID's (version 4)", - "externalDocs": { - "description": "Find out more", - "url": "https://hipstapas.dev/docs" - } - }, - { - "name": "wordlist", - "description": "Generate passphrases using the EFF wordlists", - "externalDocs": { - "description": "Find out more", - "url": "https://hipstapas.dev/docs" - } + { + "name": "uuid", + "description": "Generate UUID's / GUID's (version 4)", + "externalDocs": { + "description": "Find out more", + "url": "https://hipstapas.dev/docs" } - ], - "schemes": [ - "https" - ], - "paths": { - "/index": { - "get": { - "tags": [ - "index" - ], - "summary": "", - "description": "The default value for all boolean parameters is `true`. The default value for `lengthMin` is 16 and for `lengthMax` is 32. If `resultsCount` is set to 1, then the content type is set to `text/html`. If `resultsCount` is set to more than 1, then the content type is set to `application/json` and the result is a json array holding all generated passwords.", - "operationId": "generatePassword", - "produces": [ - "text/html", - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "alphabetSmall", - "type": "boolean", - "description": "If set to `true` the generation alphabet contains small characters: `abcdefghijklmnopqrstuvwxyz`", - "required": false - }, - { - "in": "query", - "name": "alphabetCapital", - "type": "boolean", - "description": "If set to `true` the generation alphabet contains capital characters: `ABCDEFGHIJKLMNOPQRSTUVWXYZ`", - "required": false - }, - { - "in": "query", - "name": "alphabetNumber", - "type": "boolean", - "description": "If set to `true` the generation alphabet contains numbers: `0123456789`", - "required": false - }, - { - "in": "query", - "name": "alphabetSpecial", - "type": "boolean", - "description": "If set to `true` the generation alphabet contains special characters: `.,+-*/!?;:{}()[]%$&~#@|`", - "required": false - }, - { - "in": "query", - "name": "lengthMin", - "type": "integer", - "description": "Defines the minimal length of the generated phrase", - "minimum": 1, - "maximum": 2048, - "required": false - }, - { - "in": "query", - "name": "lengthMax", - "type": "integer", - "description": "Defines the maximal length of the generated phrase", - "minimum": 1, - "maximum": 2048, - "required": false - }, - { - "in": "query", - "name": "resultsCount", - "type": "integer", - "description": "Defines how many results should be generated at once", - "minimum": 1, - "maximum": 100, - "required": false - } - ], - "responses": { - "200": { - "description": "OK. Validation errors are returned as string response." - } + }, + { + "name": "wordlist", + "description": "Generate passphrases using the EFF wordlists", + "externalDocs": { + "description": "Find out more", + "url": "https://hipstapas.dev/docs" + } + } + ], + "schemes": [ + "https" + ], + "paths": { + "/index": { + "get": { + "tags": [ + "index" + ], + "summary": "", + "description": "The default value for all boolean parameters is `true`. The default value for `lengthMin` is 16 and for `lengthMax` is 32. If `resultsCount` is set to 1, then the content type is set to `text/html`. If `resultsCount` is set to more than 1, then the content type is set to `application/json` and the result is a json array holding all generated passwords.", + "operationId": "generatePassword", + "produces": [ + "text/html", + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "alphabetSmall", + "type": "boolean", + "description": "If set to `true` the generation alphabet contains small characters: `abcdefghijklmnopqrstuvwxyz`", + "required": false + }, + { + "in": "query", + "name": "alphabetCapital", + "type": "boolean", + "description": "If set to `true` the generation alphabet contains capital characters: `ABCDEFGHIJKLMNOPQRSTUVWXYZ`", + "required": false + }, + { + "in": "query", + "name": "alphabetNumber", + "type": "boolean", + "description": "If set to `true` the generation alphabet contains numbers: `0123456789`", + "required": false + }, + { + "in": "query", + "name": "alphabetSpecial", + "type": "boolean", + "description": "If set to `true` the generation alphabet contains special characters: `.,+-*/!?;:{}()[]%$&~#@|`", + "required": false + }, + { + "in": "query", + "name": "lengthMin", + "type": "integer", + "description": "Defines the minimal length of the generated phrase", + "minimum": 1, + "maximum": 2048, + "required": false + }, + { + "in": "query", + "name": "lengthMax", + "type": "integer", + "description": "Defines the maximal length of the generated phrase", + "minimum": 1, + "maximum": 2048, + "required": false + }, + { + "in": "query", + "name": "resultsCount", + "type": "integer", + "description": "Defines how many results should be generated at once", + "minimum": 1, + "maximum": 100, + "required": false + } + ], + "responses": { + "200": { + "description": "OK. Validation errors are returned as string response." } } - }, - "/uuid": { - "get": { - "tags": [ - "uuid" - ], - "summary": "", - "description": "", - "operationId": "generateUuid", - "produces": [ - "text/html", - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "resultsCount", - "type": "integer", - "description": "Defines how many results should be generated at once", - "minimum": 1, - "maximum": 100, - "required": false - } - ], - "responses": { - "200": { - "description": "OK. Validation errors are returned as string response." - } + } + }, + "/uuid": { + "get": { + "tags": [ + "uuid" + ], + "summary": "", + "description": "", + "operationId": "generateUuid", + "produces": [ + "text/html", + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "resultsCount", + "type": "integer", + "description": "Defines how many results should be generated at once", + "minimum": 1, + "maximum": 100, + "required": false + } + ], + "responses": { + "200": { + "description": "OK. Validation errors are returned as string response." } } - }, - "/wordlist": { - "get": { - "tags": [ - "wordlist" - ], - "summary": "", - "description": "The default value for `words` is 6 - a newly generated passphrase contains 6 words (as described and suggested by EFF https://www.eff.org/de/dice)", - "operationId": "generateWordlist", - "produces": [ - "text/html", - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "words", - "type": "integer", - "description": "Defines the count of the words per passphrase", - "minimum": 1, - "maximum": 50, - "required": false - }, - { - "in": "query", - "name": "resultsCount", - "type": "integer", - "description": "Defines how many results should be generated at once", - "minimum": 1, - "maximum": 100, - "required": false - } - ], - "responses": { - "200": { - "description": "OK. Validation errors are returned as string response." - } + } + }, + "/wordlist": { + "get": { + "tags": [ + "wordlist" + ], + "summary": "", + "description": "The default value for `words` is 6 - a newly generated passphrase contains 6 words (as described and suggested by EFF https://www.eff.org/de/dice)", + "operationId": "generateWordlist", + "produces": [ + "text/html", + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "words", + "type": "integer", + "description": "Defines the count of the words per passphrase", + "minimum": 1, + "maximum": 50, + "required": false + }, + { + "in": "query", + "name": "resultsCount", + "type": "integer", + "description": "Defines how many results should be generated at once", + "minimum": 1, + "maximum": 100, + "required": false + } + ], + "responses": { + "200": { + "description": "OK. Validation errors are returned as string response." } } } }, - "externalDocs": { - "description": "Try the live interactive playground", - "url": "https://hipstapas.dev/playground" + "/random": { + "get": { + "tags": [ + "random" + ], + "summary": "", + "description": "Random ...", + "operationId": "generateRandomNumber", + "produces": [ + "text/html", + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "min", + "type": "integer", + "description": "Defines the lower bound of the number generator", + "minimum": 1, + "maximum": 1048576, + "required": false + }, + { + "in": "query", + "name": "max", + "type": "integer", + "description": "Defines the upper bound of the number generator", + "minimum": 1, + "maximum": 1048576, + "required": false + }, + { + "in": "query", + "name": "sort", + "type": "boolean", + "description": "If set to `true` the generated number sequence is sorted", + "required": false + }, + { + "in": "query", + "name": "noDuplicates", + "type": "boolean", + "description": "If set to `true` the generated number sequence contains only unique numbers", + "required": false + }, + { + "in": "query", + "name": "resultsCount", + "type": "integer", + "description": "Defines how many results should be generated at once", + "minimum": 1, + "maximum": 100, + "required": false + } + ], + "responses": { + "200": { + "description": "OK. Validation errors are returned as string response." + } + } + } } - } \ No newline at end of file + }, + "externalDocs": { + "description": "Try the live interactive playground", + "url": "https://hipstapas.dev/playground" + } +} \ No newline at end of file diff --git a/apidefinition.yaml b/apidefinition.yaml index e6f3d97..ae3771d 100644 --- a/apidefinition.yaml +++ b/apidefinition.yaml @@ -134,6 +134,51 @@ paths: responses: "200": description: "OK. Validation errors are returned as string response." + /random: + get: + tags: + - "random" + summary: "" + description: "Random ..." + operationId: "generateRandomNumber" + produces: + - "text/html" + - "application/json" + parameters: + - in: "query" + name: "min" + type: integer + description: "Defines the lower bound of the number generator" + minimum: 1 + maximum: 1048576 + required: false + - in: "query" + name: "max" + type: integer + description: "Defines the upper bound of the number generator" + minimum: 1 + maximum: 1048576 + required: false + - in: "query" + name: "sort" + type: boolean + description: "If set to `true` the generated number sequence is sorted" + required: false + - in: "query" + name: "noDuplicates" + type: boolean + description: "If set to `true` the generated number sequence contains only unique numbers" + required: false + - in: "query" + name: "resultsCount" + type: integer + description: "Defines how many results should be generated at once" + minimum: 1 + maximum: 100 + required: false + responses: + "200": + description: "OK. Validation errors are returned as string response." externalDocs: description: "Try the live interactive playground" url: "https://hipstapas.dev/playground" \ No newline at end of file