swagger docs added
This commit is contained in:
parent
2d965d53ac
commit
f962cd8cd9
5 changed files with 585 additions and 0 deletions
|
|
@ -4,12 +4,17 @@ import (
|
|||
"context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"merch-api/config"
|
||||
_ "merch-api/docs"
|
||||
"merch-api/internal/app"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// @Title Merch API
|
||||
// @Version 2.3
|
||||
// @Description Stores data about merch and prices
|
||||
// @BasePath /api/v2
|
||||
func main() {
|
||||
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer cancel()
|
||||
|
|
|
|||
233
docs/docs.go
Normal file
233
docs/docs.go
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
|
||||
const docTemplate = `{
|
||||
"schemes": {{ marshal .Schemes }},
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "{{escape .Description}}",
|
||||
"title": "{{.Title}}",
|
||||
"contact": {},
|
||||
"version": "{{.Version}}"
|
||||
},
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/merch/origins": {
|
||||
"get": {
|
||||
"description": "Get all origins",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Origins"
|
||||
],
|
||||
"summary": "Get all origins",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/merch.originsDTO"
|
||||
}
|
||||
},
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.BadRequest"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.Unauthorized"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"description": "Create new origin with name",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Origins"
|
||||
],
|
||||
"summary": "Create new origin",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "origin body",
|
||||
"name": "origin",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/merch.newOriginDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.BadRequest"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.Unauthorized"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"description": "Marks origin as deleted by name.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Origins"
|
||||
],
|
||||
"summary": "Delete origin",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "origin body",
|
||||
"name": "origin",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/merch.deleteOriginDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.BadRequest"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.Unauthorized"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"merch.deleteOriginDTO": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"merch.newOriginDTO": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"merch.originItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"merch.originsDTO": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"origins": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/merch.originItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses.BadRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string",
|
||||
"example": "error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses.InternalServerError": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string",
|
||||
"example": "error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses.Unauthorized": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string",
|
||||
"example": "error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "2.3",
|
||||
Host: "",
|
||||
BasePath: "/api/v2",
|
||||
Schemes: []string{},
|
||||
Title: "Merch API",
|
||||
Description: "Stores data about merch and prices",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
RightDelim: "}}",
|
||||
}
|
||||
|
||||
func init() {
|
||||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
||||
}
|
||||
208
docs/swagger.json
Normal file
208
docs/swagger.json
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "Stores data about merch and prices",
|
||||
"title": "Merch API",
|
||||
"contact": {},
|
||||
"version": "2.3"
|
||||
},
|
||||
"basePath": "/api/v2",
|
||||
"paths": {
|
||||
"/merch/origins": {
|
||||
"get": {
|
||||
"description": "Get all origins",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Origins"
|
||||
],
|
||||
"summary": "Get all origins",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/merch.originsDTO"
|
||||
}
|
||||
},
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.BadRequest"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.Unauthorized"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"description": "Create new origin with name",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Origins"
|
||||
],
|
||||
"summary": "Create new origin",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "origin body",
|
||||
"name": "origin",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/merch.newOriginDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.BadRequest"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.Unauthorized"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"description": "Marks origin as deleted by name.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Origins"
|
||||
],
|
||||
"summary": "Delete origin",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "origin body",
|
||||
"name": "origin",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/merch.deleteOriginDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.BadRequest"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.Unauthorized"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/responses.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"merch.deleteOriginDTO": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"merch.newOriginDTO": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"merch.originItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"merch.originsDTO": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"origins": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/merch.originItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses.BadRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string",
|
||||
"example": "error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses.InternalServerError": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string",
|
||||
"example": "error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses.Unauthorized": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string",
|
||||
"example": "error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
136
docs/swagger.yaml
Normal file
136
docs/swagger.yaml
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
basePath: /api/v2
|
||||
definitions:
|
||||
merch.deleteOriginDTO:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
merch.newOriginDTO:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
merch.originItem:
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
merch.originsDTO:
|
||||
properties:
|
||||
origins:
|
||||
items:
|
||||
$ref: '#/definitions/merch.originItem'
|
||||
type: array
|
||||
type: object
|
||||
responses.BadRequest:
|
||||
properties:
|
||||
error:
|
||||
example: error
|
||||
type: string
|
||||
type: object
|
||||
responses.InternalServerError:
|
||||
properties:
|
||||
error:
|
||||
example: error
|
||||
type: string
|
||||
type: object
|
||||
responses.Unauthorized:
|
||||
properties:
|
||||
error:
|
||||
example: error
|
||||
type: string
|
||||
type: object
|
||||
info:
|
||||
contact: {}
|
||||
description: Stores data about merch and prices
|
||||
title: Merch API
|
||||
version: "2.3"
|
||||
paths:
|
||||
/merch/origins:
|
||||
delete:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Marks origin as deleted by name.
|
||||
parameters:
|
||||
- description: origin body
|
||||
in: body
|
||||
name: origin
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/merch.deleteOriginDTO'
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/responses.BadRequest'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/responses.Unauthorized'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/responses.InternalServerError'
|
||||
summary: Delete origin
|
||||
tags:
|
||||
- Origins
|
||||
get:
|
||||
description: Get all origins
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/merch.originsDTO'
|
||||
"204":
|
||||
description: No Content
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/responses.BadRequest'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/responses.Unauthorized'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/responses.InternalServerError'
|
||||
summary: Get all origins
|
||||
tags:
|
||||
- Origins
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Create new origin with name
|
||||
parameters:
|
||||
- description: origin body
|
||||
in: body
|
||||
name: origin
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/merch.newOriginDTO'
|
||||
responses:
|
||||
"201":
|
||||
description: Created
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/responses.BadRequest'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/responses.Unauthorized'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/responses.InternalServerError'
|
||||
summary: Create new origin
|
||||
tags:
|
||||
- Origins
|
||||
swagger: "2.0"
|
||||
3
gen-swag.sh
Executable file
3
gen-swag.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
swag f
|
||||
swag init -g cmd/main.go
|
||||
Loading…
Add table
Add a link
Reference in a new issue