{"modulePath":"github.com/CaliLuke/loom","version":"v1.12.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package openapi\n\nPackage openapi provides the active schema model and shared helpers used to generate OpenAPI 3.1 and 3.2 specifications from Loom designs.\n\nThe exported schema, tag, and external-documentation types are part of the v3 document model. Rendering starts with the v3 package and keeps schema analysis state per invocation in internal/ir. This package intentionally does not provide the legacy JSON Hyper-Schema generator, global definitions registry, or compatibility aliases for those removed entry points.\n\n## Constants\n\n```go\nconst (\n\t// Array represents a JSON array.\n\tArray Type = \"array\"\n\t// Boolean represents a JSON boolean.\n\tBoolean = \"boolean\"\n\t// Integer represents a JSON number without a fraction or exponent part.\n\tInteger = \"integer\"\n\t// Number represents any JSON number. Number includes integer.\n\tNumber = \"number\"\n\t// Null represents the JSON null value.\n\tNull = \"null\"\n\t// Object represents a JSON object.\n\tObject = \"object\"\n\t// String represents a JSON string.\n\tString = \"string\"\n)\n```\n\n## Functions\n\n```go\nfunc ClosedObjectModeFromExpr(meta expr.MetaExpr) bool\n```\nClosedObjectModeFromExpr reports whether OpenAPI closed object mode is enabled via metadata.\n\n```go\nfunc ExtensionsFromExpr(mdata expr.MetaExpr) map[string]any\n```\nExtensionsFromExpr generates openapi extensions from the given meta expression.\n\n```go\nfunc MarshalJSON(v any, extensions map[string]any) ([]byte, error)\n```\nMarshalJSON produces the JSON resulting from encoding an object composed of the fields in v (which must me a struct) and the keys in extensions.\n\n```go\nfunc MarshalYAML(v any, extensions map[string]any) (any, error)\n```\nMarshalYAML produces the YAML resulting from encoding an object composed of the fields in v (which must be a struct) and the keys in extensions.\n\n```go\nfunc MergeExtensions(extensionSets ...map[string]any) map[string]any\n```\nMergeExtensions combines extension maps, with later maps taking precedence.\n\n```go\nfunc MustGenerate(meta expr.MetaExpr) bool\n```\nMustGenerate returns true if the meta indicates that a OpenAPI specification should be generated, false otherwise.\n\n```go\nfunc ScopedExtensionsFromExpr(mdata expr.MetaExpr, scope string) map[string]any\n```\nScopedExtensionsFromExpr returns OpenAPI extensions declared for scope. Scoped extension metadata uses openapi:\\\u003cscope\u003e:extension:\\\u003cx-name\u003e keys.\n\n```go\nfunc TagNamesFromExpr(mdata expr.MetaExpr) (tagNames []string)\n```\nTagNamesFromExpr computes the names of the OpenAPI tags specified in the given metadata expressions.\n\n## Types\n\n```go\ntype Discriminator struct {\n\t// PropertyName names the object property that selects the union branch.\n\tPropertyName string `json:\"propertyName\" yaml:\"propertyName\"`\n\t// Mapping maps discriminator values to schema references.\n\tMapping map[string]string `json:\"mapping,omitzero,omitempty\" yaml:\"mapping,omitempty\"`\n\t// DefaultMapping identifies the fallback schema reference.\n\tDefaultMapping string `json:\"defaultMapping,omitzero\" yaml:\"defaultMapping,omitempty\"`\n\t// Extensions retains Discriminator Object extension properties.\n\tExtensions map[string]any `json:\"-\" yaml:\"-\"`\n\t// Untagged distinguishes a validation-neutral union hint from a tagged codec.\n\tUntagged bool `json:\"-\" yaml:\"-\"`\n\t// Object distinguishes a parent-object hint.\n\tObject bool `json:\"-\" yaml:\"-\"`\n\t// Optional records that the discriminator property may be omitted in OpenAPI 3.2.\n\tOptional bool `json:\"-\" yaml:\"-\"`\n}\n```\nDiscriminator represents an OpenAPI discriminator object.\n\n```go\nfunc (d Discriminator) MarshalJSON() ([]byte, error)\n```\nMarshalJSON encodes the discriminator and its extension properties.\n\n```go\nfunc (d Discriminator) MarshalYAML() (any, error)\n```\nMarshalYAML encodes the discriminator and its extension properties.\n\n```go\ntype ExternalDocs struct {\n\tDescription string `json:\"description,omitzero\"`\n\tURL         string `json:\"url,omitzero\"`\n}\n```\nExternalDocs represents an OpenAPI External Documentation object as defined in [https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#externalDocumentationObject](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#externalDocumentationObject)\n\n```go\nfunc DocsFromExpr(docs *expr.DocsExpr) *ExternalDocs\n```\nDocsFromExpr builds a ExternalDocs from the Loom docs expression. The OpenAPI External Documentation object carries no Loom-owned extension scope, so extension metadata belongs to the object that declares it.\n\n```go\ntype Schema struct {\n\t// Schema identifies the JSON Schema dialect for this schema node.\n\tSchema string `json:\"$schema,omitzero\" yaml:\"$schema,omitempty\"`\n\t// ID identifies this schema node.\n\tID string `json:\"id,omitzero\" yaml:\"id,omitempty\"`\n\t// Title is the display name of the schema.\n\tTitle string `json:\"title,omitzero\" yaml:\"title,omitempty\"`\n\t// Type is the JSON value type accepted by the schema.\n\tType Type `json:\"type,omitzero\" yaml:\"type,omitempty\"`\n\n\t// Items describes array members.\n\tItems *Schema `json:\"items,omitzero\" yaml:\"items,omitempty\"`\n\t// Properties describes named object members.\n\tProperties map[string]*Schema `json:\"properties,omitzero,omitempty\" yaml:\"properties,omitempty\"`\n\t// Defs contains schema-local reusable definitions.\n\tDefs map[string]*Schema `json:\"$defs,omitzero,omitempty\" yaml:\"$defs,omitempty\"`\n\t// Description explains the schema contract.\n\tDescription string `json:\"description,omitzero\" yaml:\"description,omitempty\"`\n\t// DefaultValue is the schema default.\n\tDefaultValue any `json:\"default,omitzero\" yaml:\"default,omitempty\"`\n\t// Example is an example value accepted by the schema.\n\tExample any `json:\"example,omitzero\" yaml:\"example,omitempty\"`\n\t// Examples contains ordered JSON values, without Example Object metadata.\n\tExamples []any `json:\"examples,omitzero,omitempty\" yaml:\"examples,omitempty\"`\n\n\t// ReadOnly marks a value as response-only.\n\tReadOnly bool `json:\"readOnly,omitzero\" yaml:\"readOnly,omitempty\"`\n\t// WriteOnly marks a value as request-only.\n\tWriteOnly bool `json:\"writeOnly,omitzero\" yaml:\"writeOnly,omitempty\"`\n\t// Deprecated marks the schema contract as deprecated.\n\tDeprecated bool `json:\"deprecated,omitzero\" yaml:\"deprecated,omitempty\"`\n\t// ContentEncoding identifies the encoding applied to string content.\n\tContentEncoding string `json:\"contentEncoding,omitzero\" yaml:\"contentEncoding,omitempty\"`\n\t// ContentMediaType identifies the media type of encoded string content.\n\tContentMediaType string `json:\"contentMediaType,omitzero\" yaml:\"contentMediaType,omitempty\"`\n\t// ContentSchema describes content after decoding ContentEncoding and ContentMediaType.\n\tContentSchema *Schema `json:\"contentSchema,omitzero\" yaml:\"contentSchema,omitempty\"`\n\t// Ref references another schema.\n\tRef string `json:\"$ref,omitzero\" yaml:\"$ref,omitempty\"`\n\n\t// Enum lists the accepted values.\n\tEnum []any `json:\"enum,omitzero,omitempty\" yaml:\"enum,omitempty\"`\n\t// Format refines the semantic format of a value.\n\tFormat string `json:\"format,omitzero\" yaml:\"format,omitempty\"`\n\t// Pattern constrains string values with a regular expression.\n\tPattern string `json:\"pattern,omitzero\" yaml:\"pattern,omitempty\"`\n\t// ExclusiveMinimum is the exclusive numeric lower bound.\n\tExclusiveMinimum *expr.NumericBound `json:\"exclusiveMinimum,omitzero\" yaml:\"exclusiveMinimum,omitempty\"`\n\t// Minimum is the inclusive numeric lower bound.\n\tMinimum *expr.NumericBound `json:\"minimum,omitzero\" yaml:\"minimum,omitempty\"`\n\t// ExclusiveMaximum is the exclusive numeric upper bound.\n\tExclusiveMaximum *expr.NumericBound `json:\"exclusiveMaximum,omitzero\" yaml:\"exclusiveMaximum,omitempty\"`\n\t// Maximum is the inclusive numeric upper bound.\n\tMaximum *expr.NumericBound `json:\"maximum,omitzero\" yaml:\"maximum,omitempty\"`\n\t// MinLength is the minimum string length.\n\tMinLength *int `json:\"minLength,omitzero\" yaml:\"minLength,omitempty\"`\n\t// MaxLength is the maximum string length.\n\tMaxLength *int `json:\"maxLength,omitzero\" yaml:\"maxLength,omitempty\"`\n\t// MinItems is the minimum array length.\n\tMinItems *int `json:\"minItems,omitzero\" yaml:\"minItems,omitempty\"`\n\t// MaxItems is the maximum array length.\n\tMaxItems *int `json:\"maxItems,omitzero\" yaml:\"maxItems,omitempty\"`\n\t// MinProperties is the minimum number of object properties.\n\tMinProperties *int `json:\"minProperties,omitzero\" yaml:\"minProperties,omitempty\"`\n\t// MaxProperties is the maximum number of object properties.\n\tMaxProperties *int `json:\"maxProperties,omitzero\" yaml:\"maxProperties,omitempty\"`\n\t// Required lists required object property names.\n\tRequired []string `json:\"required,omitzero,omitempty\" yaml:\"required,omitempty\"`\n\t// AdditionalProperties controls values for otherwise unnamed properties.\n\tAdditionalProperties any `json:\"additionalProperties,omitzero\" yaml:\"additionalProperties,omitempty\"`\n\t// UnevaluatedProperties controls properties not covered by another keyword.\n\tUnevaluatedProperties any `json:\"unevaluatedProperties,omitzero\" yaml:\"unevaluatedProperties,omitempty\"`\n\n\t// Not rejects every value accepted by its child; an empty child rejects all values.\n\tNot *Schema `json:\"not,omitzero\" yaml:\"not,omitempty\"`\n\t// AllOf requires every listed schema to match.\n\tAllOf []*Schema `json:\"allOf,omitzero,omitempty\" yaml:\"allOf,omitempty\"`\n\t// AnyOf requires at least one listed schema to match.\n\tAnyOf []*Schema `json:\"anyOf,omitzero,omitempty\" yaml:\"anyOf,omitempty\"`\n\t// OneOf requires exactly one listed schema to match.\n\tOneOf []*Schema `json:\"oneOf,omitzero,omitempty\" yaml:\"oneOf,omitempty\"`\n\t// Discriminator describes union branch selection.\n\tDiscriminator *Discriminator `json:\"discriminator,omitzero\" yaml:\"discriminator,omitempty\"`\n\t// XML describes XML serialization metadata.\n\tXML *XML `json:\"xml,omitzero\" yaml:\"xml,omitempty\"`\n\n\t// Extensions contains OpenAPI extension properties.\n\tExtensions map[string]any `json:\"-\" yaml:\"-\"`\n}\n```\nSchema represents the JSON Schema vocabulary used by generated OpenAPI documents.\n\n```go\nfunc NewSchema() *Schema\n```\nNewSchema instantiates an empty schema with writable property and definition maps.\n\n```go\nfunc (s *Schema) MarshalJSON() ([]byte, error)\n```\nMarshalJSON returns the JSON encoding of s, including extensions.\n\n```go\nfunc (s *Schema) MarshalYAML() (any, error)\n```\nMarshalYAML returns the YAML representation of s, including extensions.\n\n```go\ntype Tag struct {\n\t// Name of the tag.\n\tName string `json:\"name,omitzero\" yaml:\"name,omitempty\"`\n\t// Summary is the short display label for the tag in OpenAPI 3.2.\n\tSummary string `json:\"summary,omitzero\" yaml:\"summary,omitempty\"`\n\t// Description is a short description of the tag.\n\t// GFM syntax can be used for rich text representation.\n\tDescription string `json:\"description,omitzero\" yaml:\"description,omitempty\"`\n\t// Parent names the tag that contains this tag in OpenAPI 3.2.\n\tParent string `json:\"parent,omitzero\" yaml:\"parent,omitempty\"`\n\t// Kind classifies the tag in OpenAPI 3.2.\n\tKind string `json:\"kind,omitzero\" yaml:\"kind,omitempty\"`\n\t// ExternalDocs is additional external documentation for this tag.\n\tExternalDocs *ExternalDocs `json:\"externalDocs,omitzero\" yaml:\"externalDocs,omitempty\"`\n\t// Extensions defines the OpenAPI extensions.\n\tExtensions map[string]any `json:\"-\" yaml:\"-\"`\n}\n```\nTag allows adding meta data to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag used there.\n\n```go\nfunc TagsFromExpr(mdata expr.MetaExpr) (tags []*Tag)\n```\nTagsFromExpr extracts the OpenAPI related metadata from the given expression.\n\n```go\nfunc (t Tag) MarshalJSON() ([]byte, error)\n```\nMarshalJSON returns the JSON encoding of t.\n\n```go\nfunc (t Tag) MarshalYAML() (any, error)\n```\nMarshalYAML returns value which marshaled in place of the original value\n\n```go\ntype Type string\n```\nType is the JSON type enum.\n\n```go\ntype XML struct {\n\t// Name overrides the XML node name.\n\tName string `json:\"name,omitzero\" yaml:\"name,omitempty\"`\n\t// Namespace is the absolute XML namespace URI.\n\tNamespace string `json:\"namespace,omitzero\" yaml:\"namespace,omitempty\"`\n\t// Prefix is the XML namespace prefix.\n\tPrefix string `json:\"prefix,omitzero\" yaml:\"prefix,omitempty\"`\n\t// NodeType identifies the OpenAPI 3.2 XML node kind.\n\tNodeType string `json:\"nodeType,omitzero\" yaml:\"nodeType,omitempty\"`\n\t// Attribute emits the value as an XML attribute.\n\tAttribute bool `json:\"attribute,omitzero\" yaml:\"attribute,omitempty\"`\n\t// Wrapped emits an array through a wrapping XML element.\n\tWrapped bool `json:\"wrapped,omitzero\" yaml:\"wrapped,omitempty\"`\n}\n```\nXML describes how a schema maps to XML nodes.\n\n","path":"github.com/CaliLuke/loom/http/codegen/openapi","name":"openapi","synopsis":"Package openapi provides the active schema model and shared helpers used to generate OpenAPI 3.1 and 3.2 specifications from Loom designs.","isRedistributable":true}
