api

package module
v0.0.0-...-1b1e9ae Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: GPL-3.0 Imports: 2 Imported by: 2

README

API

While working on Datetime-API, I felt the desire to professionalize the whole topic a bit. This module should make it possible to develop an API similar to the OpenAPI Specification without having to rely on its resources. Currently, the project is still very much at the beginning, but is already sufficient for the first attempts.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Info       *Info            `json:"info,omitempty"`
	Paths      map[string]*Path `json:"paths,omitempty"`
	Components *Components      `json:"components,omitempty"`
}

func GetAPIPrototype

func GetAPIPrototype(title string, description string, version string) API

func (API) ToJSONString

func (api API) ToJSONString() string

type Components

type Components struct {
	Schemas map[string]*ComponentsSchema `json:"schemas,omitempty"`
}

type ComponentsProperty

type ComponentsProperty struct {
	Type        string      `json:"type,omitempty"`
	Description string      `json:"description,omitempty"`
	Format      string      `json:"format,omitempty"`
	Example     interface{} `json:"example,omitempty"`
	Nullable    bool        `json:"nullable,omitempty"`
}

type ComponentsSchema

type ComponentsSchema struct {
	Type                 string                         `json:"type,omitempty"`
	Properties           map[string]*ComponentsProperty `json:"properties,omitempty"`
	AdditionalProperties bool                           `json:"additionalProperties,omitempty"`
}

type Contact

type Contact struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
}

type Info

type Info struct {
	Title       string   `json:"title,omitempty"`
	Description string   `json:"description,omitempty"`
	Contact     *Contact `json:"contact,omitempty"`
	Version     string   `json:"version,omitempty"`
}

type Method

type Method struct {
	Function   func(http.ResponseWriter, *http.Request) `json:"-"`
	Tags       []string                                 `json:"tags,omitempty"`
	Summary    string                                   `json:"summary,omitempty"`
	Parameters []*Parameters                            `json:"parameters,omitempty"`
	Responses  map[int]*Response                        `json:"responses,omitempty"`
}

type Parameters

type Parameters struct {
	Name          string            `json:"name,omitempty"`
	In            string            `json:"in,omitempty"`
	Description   string            `json:"description,omitempty"`
	Schema        *ParametersSchema `json:"schema,omitempty"`
	Example       string            `json:"example,omitempty"`
	AllowReserved bool              `json:"allowReserved,omitempty"`
}

type ParametersSchema

type ParametersSchema struct {
	Type   string `json:"type,omitempty"`
	Format string `json:"format,omitempty"`
}

type Path

type Path struct {
	GET    *Method `json:"get,omitempty"`
	POST   *Method `json:"post,omitempty"`
	PUT    *Method `json:"put,omitempty"`
	DELETE *Method `json:"delete,omitempty"`
	PATCH  *Method `json:"patch,omitempty"`
}

type Response

type Response struct {
	Description string                      `json:"description,omitempty"`
	Content     map[string]*ResponseContent `json:"content,omitempty"`
}

type ResponseContent

type ResponseContent struct {
	Schema *ResponseSchema `json:"schema,omitempty"`
}

type ResponseSchema

type ResponseSchema struct {
	Type string `json:"type,omitempty"`
	Ref  string `json:"$ref,omitempty"`
}

Jump to

Keyboard shortcuts

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