From 5f389ae5f8bdb4c3569a22dfd8e54935c425a86d Mon Sep 17 00:00:00 2001 From: YuukanOO Date: Fri, 18 Dec 2020 15:06:24 +0100 Subject: [PATCH] generate swagger.json on build --- Apps/Api/Api.csproj | 10 +++ Apps/Api/swagger.json | 158 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 Apps/Api/swagger.json diff --git a/Apps/Api/Api.csproj b/Apps/Api/Api.csproj index 2751af7..f245fe5 100644 --- a/Apps/Api/Api.csproj +++ b/Apps/Api/Api.csproj @@ -3,6 +3,7 @@ true $(NoWarn);1591 + @@ -11,11 +12,20 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + net5.0 + + + + + diff --git a/Apps/Api/swagger.json b/Apps/Api/swagger.json new file mode 100644 index 0000000..248b757 --- /dev/null +++ b/Apps/Api/swagger.json @@ -0,0 +1,158 @@ +{ + "x-generator": "NSwag v13.9.4.0 (NJsonSchema v10.3.1.0 (Newtonsoft.Json v12.0.0.0))", + "openapi": "3.0.0", + "info": { + "title": "Hacker news like API in .Net", + "version": "1.0.0" + }, + "paths": { + "/api/links": { + "get": { + "tags": [ + "Links" + ], + "summary": "Retrieve all links already posted.", + "operationId": "Links_GetLinks", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LinkDto" + } + } + } + } + }, + "400": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemDetails" + } + } + } + } + } + }, + "post": { + "tags": [ + "Links" + ], + "summary": "Post a new link.", + "operationId": "Links_CreateLink", + "requestBody": { + "x-name": "command", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AddLinkCommand" + } + } + }, + "required": true, + "x-position": 1 + }, + "responses": { + "200": { + "description": "", + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "LinkDto": { + "type": "object", + "additionalProperties": false, + "properties": { + "id": { + "type": "string", + "format": "guid" + }, + "url": { + "type": "string", + "nullable": true + }, + "createdAt": { + "type": "string", + "format": "date-time" + }, + "createdByName": { + "type": "string", + "nullable": true + }, + "upVotes": { + "type": "integer", + "format": "int32" + }, + "downVotes": { + "type": "integer", + "format": "int32" + } + } + }, + "ProblemDetails": { + "type": "object", + "additionalProperties": { + "nullable": true + }, + "properties": { + "type": { + "type": "string", + "nullable": true + }, + "title": { + "type": "string", + "nullable": true + }, + "status": { + "type": "integer", + "format": "int32", + "nullable": true + }, + "detail": { + "type": "string", + "nullable": true + }, + "instance": { + "type": "string", + "nullable": true + }, + "extensions": { + "type": "object", + "nullable": true, + "additionalProperties": {} + } + } + }, + "AddLinkCommand": { + "type": "object", + "additionalProperties": false, + "required": [ + "url" + ], + "properties": { + "url": { + "type": "string", + "format": "uri", + "minLength": 1 + } + } + } + } + } +} \ No newline at end of file