basic swagger

This commit is contained in:
2024-11-26 11:32:20 -06:00
parent 052f95702d
commit ca17c0645d
3 changed files with 304 additions and 0 deletions

129
docs/docs.go Normal file
View File

@@ -0,0 +1,129 @@
// 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}}",
"termsOfService": "http://nkode.example.com/terms/",
"contact": {
"name": "API Support",
"url": "http://nkode.example.com/support",
"email": "support@nkode.example.com"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/create-new-customer": {
"post": {
"description": "Creates a new customer based on the provided policy information.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"customers"
],
"summary": "Create a new customer",
"parameters": [
{
"description": "Customer creation data",
"name": "NewCustomerPost",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/core.NewCustomerPost"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/core.CreateNewCustomerResp"
}
}
}
}
}
},
"definitions": {
"core.CreateNewCustomerResp": {
"type": "object",
"properties": {
"customer_id": {
"type": "string"
}
}
},
"core.NKodePolicy": {
"type": "object",
"properties": {
"distinct_attributes": {
"type": "integer"
},
"distinct_sets": {
"type": "integer"
},
"expiration": {
"description": "seconds, -1 no expiration",
"type": "integer"
},
"lock_out": {
"type": "integer"
},
"max_nkode_len": {
"type": "integer"
},
"min_nkode_len": {
"type": "integer"
}
}
},
"core.NewCustomerPost": {
"type": "object",
"properties": {
"nkode_policy": {
"$ref": "#/definitions/core.NKodePolicy"
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:8080",
BasePath: "/",
Schemes: []string{},
Title: "NKode API",
Description: "This is the NKode API server.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}

105
docs/swagger.json Normal file
View File

@@ -0,0 +1,105 @@
{
"swagger": "2.0",
"info": {
"description": "This is the NKode API server.",
"title": "NKode API",
"termsOfService": "http://nkode.example.com/terms/",
"contact": {
"name": "API Support",
"url": "http://nkode.example.com/support",
"email": "support@nkode.example.com"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
},
"version": "1.0"
},
"host": "localhost:8080",
"basePath": "/",
"paths": {
"/create-new-customer": {
"post": {
"description": "Creates a new customer based on the provided policy information.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"customers"
],
"summary": "Create a new customer",
"parameters": [
{
"description": "Customer creation data",
"name": "NewCustomerPost",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/core.NewCustomerPost"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/core.CreateNewCustomerResp"
}
}
}
}
}
},
"definitions": {
"core.CreateNewCustomerResp": {
"type": "object",
"properties": {
"customer_id": {
"type": "string"
}
}
},
"core.NKodePolicy": {
"type": "object",
"properties": {
"distinct_attributes": {
"type": "integer"
},
"distinct_sets": {
"type": "integer"
},
"expiration": {
"description": "seconds, -1 no expiration",
"type": "integer"
},
"lock_out": {
"type": "integer"
},
"max_nkode_len": {
"type": "integer"
},
"min_nkode_len": {
"type": "integer"
}
}
},
"core.NewCustomerPost": {
"type": "object",
"properties": {
"nkode_policy": {
"$ref": "#/definitions/core.NKodePolicy"
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}

70
docs/swagger.yaml Normal file
View File

@@ -0,0 +1,70 @@
basePath: /
definitions:
core.CreateNewCustomerResp:
properties:
customer_id:
type: string
type: object
core.NKodePolicy:
properties:
distinct_attributes:
type: integer
distinct_sets:
type: integer
expiration:
description: seconds, -1 no expiration
type: integer
lock_out:
type: integer
max_nkode_len:
type: integer
min_nkode_len:
type: integer
type: object
core.NewCustomerPost:
properties:
nkode_policy:
$ref: '#/definitions/core.NKodePolicy'
type: object
host: localhost:8080
info:
contact:
email: support@nkode.example.com
name: API Support
url: http://nkode.example.com/support
description: This is the NKode API server.
license:
name: MIT
url: https://opensource.org/licenses/MIT
termsOfService: http://nkode.example.com/terms/
title: NKode API
version: "1.0"
paths:
/create-new-customer:
post:
consumes:
- application/json
description: Creates a new customer based on the provided policy information.
parameters:
- description: Customer creation data
in: body
name: NewCustomerPost
required: true
schema:
$ref: '#/definitions/core.NewCustomerPost'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/core.CreateNewCustomerResp'
summary: Create a new customer
tags:
- customers
securityDefinitions:
ApiKeyAuth:
in: header
name: Authorization
type: apiKey
swagger: "2.0"