openapi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package openapi holds the OpenAPI document model of Auth-All. Core and plugins contribute operations. The document drives the generated TypeScript client and the published API contract.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientBinding

type ClientBinding struct {
	Namespace string `json:"namespace,omitempty"`
	Method    string `json:"method"`
	// Redirect marks an operation that a browser follows instead of fetching.
	Redirect bool `json:"redirect,omitempty"`
}

ClientBinding tells the client generator how to expose one operation.

A namespace groups methods, so a binding of namespace "signIn" and method "email" becomes auth.signIn.email(...) in the generated TypeScript client.

type Components

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

Components holds reusable schemas.

type Document

type Document struct {
	OpenAPI    string              `json:"openapi"`
	Info       Info                `json:"info"`
	Servers    []Server            `json:"servers,omitempty"`
	Paths      map[string]PathItem `json:"paths"`
	Components Components          `json:"components"`
}

Document is an OpenAPI 3.0.3 document.

func New

func New(title, version string) *Document

New returns an empty document.

func (*Document) AddOperation

func (d *Document) AddOperation(method, path string, op *Operation)

AddOperation registers one operation. A duplicate method and path pair replaces the previous entry.

func (*Document) AddSchema

func (d *Document) AddSchema(name string, s *Schema)

AddSchema registers one reusable component schema.

type Info

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

Info describes the API.

type MediaType

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

MediaType binds a schema to a content type.

type Operation

type Operation struct {
	OperationID string              `json:"operationId"`
	Summary     string              `json:"summary,omitempty"`
	Description string              `json:"description,omitempty"`
	Tags        []string            `json:"tags,omitempty"`
	Parameters  []Parameter         `json:"parameters,omitempty"`
	RequestBody *RequestBody        `json:"requestBody,omitempty"`
	Responses   map[string]Response `json:"responses"`
	Client      *ClientBinding      `json:"x-authall-client,omitempty"`
}

Operation is one HTTP operation.

type Parameter

type Parameter struct {
	Name        string  `json:"name"`
	In          string  `json:"in"`
	Required    bool    `json:"required,omitempty"`
	Description string  `json:"description,omitempty"`
	Schema      *Schema `json:"schema,omitempty"`
}

Parameter is one query or path parameter.

type PathItem

type PathItem map[string]*Operation

PathItem maps a lowercase HTTP method to one operation.

type RequestBody

type RequestBody struct {
	Required bool                 `json:"required,omitempty"`
	Content  map[string]MediaType `json:"content"`
}

RequestBody is a JSON request body.

func JSONBody

func JSONBody(s *Schema) *RequestBody

JSONBody returns a required JSON request body for one schema.

type Response

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

Response is one response.

func JSONResponse

func JSONResponse(description string, s *Schema) Response

JSONResponse returns a JSON response for one schema.

type Schema

type Schema struct {
	Ref                  string             `json:"$ref,omitempty"`
	Type                 string             `json:"type,omitempty"`
	Format               string             `json:"format,omitempty"`
	Description          string             `json:"description,omitempty"`
	Nullable             bool               `json:"nullable,omitempty"`
	Properties           map[string]*Schema `json:"properties,omitempty"`
	Required             []string           `json:"required,omitempty"`
	Items                *Schema            `json:"items,omitempty"`
	Enum                 []string           `json:"enum,omitempty"`
	AdditionalProperties *Schema            `json:"additionalProperties,omitempty"`
}

Schema is a JSON schema subset.

func Bool

func Bool() *Schema

Bool returns a boolean schema.

func Object

func Object(required []string, props map[string]*Schema) *Schema

Object returns an object schema.

func Ref

func Ref(name string) *Schema

Ref returns a reference to a component schema.

func String

func String() *Schema

String returns a string schema.

type Server

type Server struct {
	URL         string `json:"url"`
	Description string `json:"description,omitempty"`
}

Server is one base URL.

Jump to

Keyboard shortcuts

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