{"modulePath":"github.com/bitechdev/ResolveSpec","version":"v1.3.14","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package openapi\n\n## Functions\n\n```go\nfunc ExampleBothSpecs(db *gorm.DB)\n```\nExampleBothSpecs shows how to combine both RestheadSpec and ResolveSpec\n\n```go\nfunc ExampleCustomization()\n```\nExampleCustomization shows advanced customization options\n\n```go\nfunc ExampleResolveSpec(db *gorm.DB)\n```\nExampleResolveSpec shows how to configure OpenAPI generation for ResolveSpec\n\n```go\nfunc ExampleRestheadSpec(db *gorm.DB)\n```\nExampleRestheadSpec shows how to configure OpenAPI generation for RestheadSpec\n\n```go\nfunc ExampleWithFuncSpec()\n```\nExampleWithFuncSpec shows how to add FuncSpec endpoints to OpenAPI\n\n```go\nfunc ExampleWithUIHandler(db *gorm.DB)\n```\nExampleWithUIHandler shows how to serve OpenAPI documentation with a web UI\n\n```go\nfunc SetupUIRoute(router *mux.Router, path string, config UIConfig)\n```\nSetupUIRoute adds the OpenAPI UI route to a mux router This is a convenience function for the most common use case\n\n```go\nfunc UIHandler(config UIConfig) http.HandlerFunc\n```\nUIHandler creates an HTTP handler that serves an OpenAPI UI\n\n## Types\n\n```go\ntype Components struct {\n\tSchemas         map[string]Schema         `json:\"schemas,omitempty\"`\n\tSecuritySchemes map[string]SecurityScheme `json:\"securitySchemes,omitempty\"`\n}\n```\n\n```go\ntype Contact struct {\n\tName  string `json:\"name,omitempty\"`\n\tURL   string `json:\"url,omitempty\"`\n\tEmail string `json:\"email,omitempty\"`\n}\n```\n\n```go\ntype FuncSpecEndpoint struct {\n\tPath        string\n\tMethod      string\n\tSummary     string\n\tDescription string\n\tSQLQuery    string\n\tParameters  []string // Parameter names extracted from SQL\n}\n```\nFuncSpecEndpoint represents a FuncSpec endpoint for OpenAPI generation\n\n```go\ntype Generator struct {\n\t// contains filtered or unexported fields\n}\n```\nGenerator creates OpenAPI specifications\n\n```go\nfunc NewGenerator(config GeneratorConfig) *Generator\n```\nNewGenerator creates a new OpenAPI generator\n\n```go\nfunc (g *Generator) Generate() (*OpenAPISpec, error)\n```\nGenerate creates the complete OpenAPI specification\n\n```go\nfunc (g *Generator) GenerateJSON() (string, error)\n```\nGenerateJSON generates OpenAPI spec as JSON string\n\n```go\ntype GeneratorConfig struct {\n\tTitle               string\n\tDescription         string\n\tVersion             string\n\tBaseURL             string\n\tRegistry            *modelregistry.DefaultModelRegistry\n\tIncludeRestheadSpec bool\n\tIncludeResolveSpec  bool\n\tIncludeFuncSpec     bool\n\tFuncSpecEndpoints   map[string]FuncSpecEndpoint // path -\u003e endpoint info\n}\n```\nGeneratorConfig holds configuration for OpenAPI spec generation\n\n```go\ntype Info struct {\n\tTitle       string   `json:\"title\"`\n\tDescription string   `json:\"description,omitempty\"`\n\tVersion     string   `json:\"version\"`\n\tContact     *Contact `json:\"contact,omitempty\"`\n}\n```\n\n```go\ntype MediaType struct {\n\tSchema  *Schema     `json:\"schema,omitempty\"`\n\tExample interface{} `json:\"example,omitempty\"`\n}\n```\n\n```go\ntype OpenAPISpec struct {\n\tOpenAPI    string                `json:\"openapi\"`\n\tInfo       Info                  `json:\"info\"`\n\tServers    []Server              `json:\"servers,omitempty\"`\n\tPaths      map[string]PathItem   `json:\"paths\"`\n\tComponents Components            `json:\"components\"`\n\tSecurity   []map[string][]string `json:\"security,omitempty\"`\n}\n```\nOpenAPISpec represents the OpenAPI 3.0 specification structure\n\n```go\ntype Operation struct {\n\tSummary     string                `json:\"summary,omitempty\"`\n\tDescription string                `json:\"description,omitempty\"`\n\tOperationID string                `json:\"operationId,omitempty\"`\n\tTags        []string              `json:\"tags,omitempty\"`\n\tParameters  []Parameter           `json:\"parameters,omitempty\"`\n\tRequestBody *RequestBody          `json:\"requestBody,omitempty\"`\n\tResponses   map[string]Response   `json:\"responses\"`\n\tSecurity    []map[string][]string `json:\"security,omitempty\"`\n}\n```\n\n```go\ntype Parameter struct {\n\tName        string      `json:\"name\"`\n\tIn          string      `json:\"in\"` // \"query\", \"header\", \"path\", \"cookie\"\n\tDescription string      `json:\"description,omitempty\"`\n\tRequired    bool        `json:\"required,omitempty\"`\n\tSchema      *Schema     `json:\"schema,omitempty\"`\n\tExample     interface{} `json:\"example,omitempty\"`\n}\n```\n\n```go\ntype PathItem struct {\n\tGet     *Operation `json:\"get,omitempty\"`\n\tPost    *Operation `json:\"post,omitempty\"`\n\tPut     *Operation `json:\"put,omitempty\"`\n\tPatch   *Operation `json:\"patch,omitempty\"`\n\tDelete  *Operation `json:\"delete,omitempty\"`\n\tOptions *Operation `json:\"options,omitempty\"`\n}\n```\n\n```go\ntype RequestBody struct {\n\tDescription string               `json:\"description,omitempty\"`\n\tRequired    bool                 `json:\"required,omitempty\"`\n\tContent     map[string]MediaType `json:\"content\"`\n}\n```\n\n```go\ntype Response struct {\n\tDescription string               `json:\"description\"`\n\tContent     map[string]MediaType `json:\"content,omitempty\"`\n}\n```\n\n```go\ntype Schema struct {\n\tType                 string             `json:\"type,omitempty\"`\n\tFormat               string             `json:\"format,omitempty\"`\n\tDescription          string             `json:\"description,omitempty\"`\n\tProperties           map[string]*Schema `json:\"properties,omitempty\"`\n\tItems                *Schema            `json:\"items,omitempty\"`\n\tRequired             []string           `json:\"required,omitempty\"`\n\tRef                  string             `json:\"$ref,omitempty\"`\n\tEnum                 []interface{}      `json:\"enum,omitempty\"`\n\tExample              interface{}        `json:\"example,omitempty\"`\n\tAdditionalProperties interface{}        `json:\"additionalProperties,omitempty\"`\n\tOneOf                []*Schema          `json:\"oneOf,omitempty\"`\n\tAnyOf                []*Schema          `json:\"anyOf,omitempty\"`\n}\n```\n\n```go\ntype SecurityScheme struct {\n\tType         string `json:\"type\"` // \"apiKey\", \"http\", \"oauth2\", \"openIdConnect\"\n\tDescription  string `json:\"description,omitempty\"`\n\tName         string `json:\"name,omitempty\"`         // For apiKey\n\tIn           string `json:\"in,omitempty\"`           // For apiKey: \"query\", \"header\", \"cookie\"\n\tScheme       string `json:\"scheme,omitempty\"`       // For http: \"basic\", \"bearer\"\n\tBearerFormat string `json:\"bearerFormat,omitempty\"` // For http bearer\n}\n```\n\n```go\ntype Server struct {\n\tURL         string `json:\"url\"`\n\tDescription string `json:\"description,omitempty\"`\n}\n```\n\n```go\ntype UIConfig struct {\n\t// UIType specifies which UI framework to use (default: SwaggerUI)\n\tUIType UIType\n\t// SpecURL is the URL to the OpenAPI spec JSON (default: \"/openapi\")\n\tSpecURL string\n\t// Title is the page title (default: \"API Documentation\")\n\tTitle string\n\t// FaviconURL is the URL to the favicon (optional)\n\tFaviconURL string\n\t// CustomCSS allows injecting custom CSS (optional)\n\tCustomCSS string\n\t// Theme for the UI (light/dark, depends on UI type)\n\tTheme string\n}\n```\nUIConfig holds configuration for the OpenAPI UI handler\n\n```go\ntype UIType string\n```\nUIType represents the type of OpenAPI UI to serve\n\n```go\nconst (\n\t// SwaggerUI is the most popular OpenAPI UI\n\tSwaggerUI UIType = \"swagger-ui\"\n\t// RapiDoc is a modern, customizable OpenAPI UI\n\tRapiDoc UIType = \"rapidoc\"\n\t// Redoc is a clean, responsive OpenAPI UI\n\tRedoc UIType = \"redoc\"\n\t// Scalar is a modern and sleek OpenAPI UI\n\tScalar UIType = \"scalar\"\n)\n```\n\n","path":"github.com/bitechdev/ResolveSpec/pkg/openapi","name":"openapi","synopsis":"","isRedistributable":true}
