-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π feat: add swagger documentation and improve project structure
β¨ feat: add API documentation with swagger and OpenAPI specs β»οΈ refactor: reorganize server initialization and cleanup process π§ fix: update build paths in air.toml and Dockerfile The changes include: 1. Adding swagger documentation for API endpoints 2. Restructuring server initialization with proper cleanup 3. Moving main.go to root directory 4. Updating build configuration files 5. Adding API documentation endpoints and handlers
- Loading branch information
Showing
14 changed files
with
373 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/docs/ | ||
/lib/ | ||
/bin/ | ||
/uploads/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// 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": {}, | ||
"license": { | ||
"name": "MIT", | ||
"url": "https://github.com/watzon/0x45/blob/main/LICENSE" | ||
}, | ||
"version": "{{.Version}}" | ||
}, | ||
"host": "{{.Host}}", | ||
"basePath": "{{.BasePath}}", | ||
"paths": { | ||
"/api/keys/request": { | ||
"post": { | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"API Key" | ||
], | ||
"summary": "Request a new API key", | ||
"operationId": "HandleRequestAPIKey", | ||
"parameters": [ | ||
{ | ||
"description": "Request a new API key", | ||
"name": "request", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"$ref": "#/definitions/services.APIKeyRequest" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/services.APIKeyResponse" | ||
} | ||
}, | ||
"400": { | ||
"description": "Bad Request", | ||
"schema": { | ||
"$ref": "#/definitions/services.APIKeyResponse" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"services.APIKeyRequest": { | ||
"type": "object", | ||
"properties": { | ||
"email": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"services.APIKeyResponse": { | ||
"type": "object", | ||
"properties": { | ||
"key": { | ||
"type": "string" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
|
||
// SwaggerInfo holds exported Swagger Info so clients can modify it | ||
var SwaggerInfo = &swag.Spec{ | ||
Version: "1.0", | ||
Host: "localhost:3000", | ||
BasePath: "/", | ||
Schemes: []string{}, | ||
Title: "0x45 API", | ||
Description: "API for 0x45", | ||
InfoInstanceName: "swagger", | ||
SwaggerTemplate: docTemplate, | ||
LeftDelim: "{{", | ||
RightDelim: "}}", | ||
} | ||
|
||
func init() { | ||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "API for 0x45", | ||
"title": "0x45 API", | ||
"contact": {}, | ||
"license": { | ||
"name": "MIT", | ||
"url": "https://github.com/watzon/0x45/blob/main/LICENSE" | ||
}, | ||
"version": "1.0" | ||
}, | ||
"host": "localhost:3000", | ||
"basePath": "/", | ||
"paths": { | ||
"/api/keys/request": { | ||
"post": { | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"API Key" | ||
], | ||
"summary": "Request a new API key", | ||
"operationId": "HandleRequestAPIKey", | ||
"parameters": [ | ||
{ | ||
"description": "Request a new API key", | ||
"name": "request", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"$ref": "#/definitions/services.APIKeyRequest" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/services.APIKeyResponse" | ||
} | ||
}, | ||
"400": { | ||
"description": "Bad Request", | ||
"schema": { | ||
"$ref": "#/definitions/services.APIKeyResponse" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"services.APIKeyRequest": { | ||
"type": "object", | ||
"properties": { | ||
"email": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"services.APIKeyResponse": { | ||
"type": "object", | ||
"properties": { | ||
"key": { | ||
"type": "string" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
basePath: / | ||
definitions: | ||
services.APIKeyRequest: | ||
properties: | ||
email: | ||
type: string | ||
name: | ||
type: string | ||
type: object | ||
services.APIKeyResponse: | ||
properties: | ||
key: | ||
type: string | ||
message: | ||
type: string | ||
type: object | ||
host: localhost:3000 | ||
info: | ||
contact: {} | ||
description: API for 0x45 | ||
license: | ||
name: MIT | ||
url: https://github.com/watzon/0x45/blob/main/LICENSE | ||
title: 0x45 API | ||
version: "1.0" | ||
paths: | ||
/api/keys/request: | ||
post: | ||
consumes: | ||
- application/json | ||
operationId: HandleRequestAPIKey | ||
parameters: | ||
- description: Request a new API key | ||
in: body | ||
name: request | ||
required: true | ||
schema: | ||
$ref: '#/definitions/services.APIKeyRequest' | ||
produces: | ||
- application/json | ||
responses: | ||
"200": | ||
description: OK | ||
schema: | ||
$ref: '#/definitions/services.APIKeyResponse' | ||
"400": | ||
description: Bad Request | ||
schema: | ||
$ref: '#/definitions/services.APIKeyResponse' | ||
summary: Request a new API key | ||
tags: | ||
- API Key | ||
swagger: "2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.