canopsis-api-community

command
v0.0.0-...-9b5cd94 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

README

Community API

Deployment

Use configuration dir. Provide the path to the config through -c argument.

Use -port to change API port.

Use -d to enable debug mode.

Use -docs to enable Open API documentation on /swagger endpoint.

Documentation

How to add new endpoint to Open API documentation:

  1. For POST and PUT requests add a model to a handler comment.

    // @Param request body CreateRequest true "request"
    func (a *api) Create(c *gin.Context) {
    
    }
    
  2. Add new response model to a handler comment.

    // @Success 201 {object} Rule
    func (a *api) Create(c *gin.Context) {
    
    }
    
  3. Generate Open API schemas documentation for Golang structs using go:generate in main.go.

  4. Use generated schemas in Open API v3 documentation.

    paths:
      /rules:
        post:
          requestBody:
            required: true
            content:
              application/json:
                schema:
                  $ref: 'schemas_swagger.yaml#/definitions/rule.CreateRequest'
          responses:
            201:
              content:
                application/json:
                  schema:
                    $ref: 'schemas_swagger.yaml#/definitions/rule.Rule'
    

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL