Documentation
¶
Index ¶
- Variables
- func AddComponentSchemaPrefix(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func AddIdempotencyKey(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func AddPathPrefix(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func ApplyPatches(input []byte, patches []sharedpatch.SpecPatch) ([]byte, error)
- func FixCommon(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixInvalidMaxValue(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixMissingSchemaTitle(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixOAS300Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixOAS301Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixOAS302Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixOAS303Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixOAS304Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixOAS310Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixOAS311Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixOperationTags(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FixRemoveCommonOperationIdPrefix(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func FlattenComponents(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func GenerateMissingOperationIds(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func GenerateOpenAPIOverlay(doc *libopenapi.DocumentModel[v3.Document], id string) ([]byte, error)
- func GenerateOperationIds(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func GenerateTagFromDocTitle(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func LLMOperationIDPatch(doc *libopenapi.DocumentModel[v3.Document]) ([]byte, error)
- func MergePolymorphicProperties(v3Model *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func MergePolymorphicSchemas(v3Model *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func PruneDocumentTags(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func PruneInvalidPaths(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func PruneOperationTags(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func PruneOperationTagsExceptFirst(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func PrunePathPrefix(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func PruneUnusualPaths(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func ResolvePatchSets(patchSets []PatchSet) []sharedpatch.SpecPatch
- func SetEndpoint(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func SetOperationTag(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func SimplifyAllOf(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func SimplifyPolymorphicBooleans(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
- func SpeakeasyCleanup(inputFile string, config map[string]interface{}) ([]byte, error)
- func SpeakeasyFormat(inputFile string, config map[string]interface{}) ([]byte, error)
- func SpeakeasyNormalize(inputFile string, config map[string]interface{}) ([]byte, error)
- func SpeakeasyRemoveUnused(inputFile string, config map[string]interface{}) ([]byte, error)
- type BuiltInPatcher
- type PatchPreset
- type PatchSet
Constants ¶
This section is empty.
Variables ¶
var AddComponentSchemaPrefixPatch = BuiltInPatcher{ Type: "builtin", ID: "add-component-schema-prefix", Description: "Adds a prefix to all component schemas in the OpenAPI document", PatchV3DocumentFunc: AddComponentSchemaPrefix, }
var AddIdempotencyKeyPatch = BuiltInPatcher{ Type: "builtin", ID: "add-idempotency-key", Description: "Adds an idempotency key to all POST operations in the OpenAPI document (see https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header)", PatchV3DocumentFunc: AddIdempotencyKey, }
var AddPathPrefixPatch = BuiltInPatcher{ Type: "builtin", ID: "add-path-prefix", Description: "Adds a prefix to all paths in the OpenAPI document", PatchV3DocumentFunc: AddPathPrefix, }
var EmbeddedPatcherMap = util.SliceToMapWithKeyFunc(EmbeddedPatchers, func(p BuiltInPatcher) string {
return p.Type + ":" + p.ID
})
var EmbeddedPatchers = []BuiltInPatcher{ FixOAS300VersionPatch, FixOAS301VersionPatch, FixOAS302VersionPatch, FixOAS303VersionPatch, FixOAS304VersionPatch, FixOAS310VersionPatch, FixOAS311VersionPatch, FixCommonPatch, FixInvalidMaxValuePatch, FixOperationTagsPatch, FixMissingSchemaTitlePatch, FixRemoveCommonOperationIdPrefixPatch, FlattenComponentsPatch, MergePolymorphicSchemasPatch, SimplifyPolymorphicBooleansPatch, MergePolymorphicPropertiesPatch, SimplifyAllOfPatch, PruneInvalidPathsPatch, PruneUnusualPathsPatch, PruneDocumentTagsPatch, PruneOperationTagsPatch, PruneOperationTagsExceptFirstPatch, GenerateTagFromDocTitlePatch, GenerateOperationIdsPatch, GenerateMissingOperationIdsPatch, SetEndpointPatch, AddIdempotencyKeyPatch, SetOperationTagPatch, AddPathPrefixPatch, PrunePathPrefixPatch, AddComponentSchemaPrefixPatch, SpeakeasyRemoveUnusedPatch, SpeakeasyCleanupPatch, SpeakeasyFormatPatch, SpeakeasyNormalizePatch, }
var FixCommonPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-common", Description: "Fixes various common issues.", PatchV3DocumentFunc: FixCommon, }
var FixInvalidMaxValuePatch = BuiltInPatcher{ Type: "builtin", ID: "fix-invalid-max-value", Description: "Fixes integer and long schemas where the maximum value is out of bounds for the type, e.g. max: 9223372036854775807 for long.", PatchV3DocumentFunc: FixInvalidMaxValue, }
var FixMissingSchemaTitlePatch = BuiltInPatcher{ Type: "builtin", ID: "fix-missing-schema-title", Description: "Adds a title to all schemas that are missing a title", PatchV3DocumentFunc: FixMissingSchemaTitle, }
var FixOAS300VersionPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-oas-300-version", Description: "Fixes specs authored in OpenAPI 3.0.0 format but mistakenly labeled as a different version, without converting schema content.", PatchV3DocumentFunc: FixOAS300Version, }
var FixOAS301VersionPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-oas-301-version", Description: "Fixes specs authored in OpenAPI 3.0.1 format but mistakenly labeled as a different version, without converting schema content.", PatchV3DocumentFunc: FixOAS301Version, }
var FixOAS302VersionPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-oas-302-version", Description: "Fixes specs authored in OpenAPI 3.0.2 format but mistakenly labeled as a different version, without converting schema content.", PatchV3DocumentFunc: FixOAS302Version, }
var FixOAS303VersionPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-oas-303-version", Description: "Fixes specs authored in OpenAPI 3.0.3 format but mistakenly labeled as a different version, without converting schema content.", PatchV3DocumentFunc: FixOAS303Version, }
var FixOAS304VersionPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-oas-304-version", Description: "Fixes specs authored in OpenAPI 3.0.4 format but mistakenly labeled as a different version, without converting schema content.", PatchV3DocumentFunc: FixOAS304Version, }
var FixOAS310VersionPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-oas-310-version", Description: "Fixes specs authored in OpenAPI 3.1.0 format but mistakenly labeled as a different version, without converting schema content.", PatchV3DocumentFunc: FixOAS310Version, }
var FixOAS311VersionPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-oas-311-version", Description: "Fixes specs authored in OpenAPI 3.1.1 format but mistakenly labeled as a different version, without converting schema content.", PatchV3DocumentFunc: FixOAS311Version, }
var FixOperationTagsPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-operation-tags", Description: "Ensures all operations have at least one tag, and that tags are documented in the document", PatchV3DocumentFunc: FixOperationTags, }
var FixRemoveCommonOperationIdPrefixPatch = BuiltInPatcher{ Type: "builtin", ID: "fix-remove-common-operation-id-prefix", Description: "Removes common prefixes from operation IDs", PatchV3DocumentFunc: FixRemoveCommonOperationIdPrefix, }
var FlattenComponentsPatch = BuiltInPatcher{ Type: "builtin", ID: "flatten-components", Description: "Flattens inline request bodies and response schemas into the components section of the document", PatchV3DocumentFunc: FlattenComponents, }
var GenerateMissingOperationIdsPatch = BuiltInPatcher{ Type: "builtin", ID: "generate-missing-operation-id", Description: "Generates operation IDs for all operations that are missing an ID (does not overwrite existing IDs)", PatchV3DocumentFunc: GenerateMissingOperationIds, }
var GenerateOperationIdsPatch = BuiltInPatcher{ Type: "builtin", ID: "generate-operation-id", Description: "Generates operation IDs for all operations (overwrites existing IDs)", PatchV3DocumentFunc: GenerateOperationIds, }
var GenerateTagFromDocTitlePatch = BuiltInPatcher{ Type: "builtin", ID: "generate-tag-from-doc-title", Description: "Removes all tags and createsone tag based on the document title, useful when merging multiple specs", PatchV3DocumentFunc: GenerateTagFromDocTitle, }
var MergePolymorphicPropertiesPatch = BuiltInPatcher{ Type: "builtin", ID: "simplify-polymorphic-properties", Description: "Merges polymorphic property values (anyOf, oneOf, allOf) into a single flat schema referenced by properties", PatchV3DocumentFunc: MergePolymorphicProperties, }
var MergePolymorphicSchemasPatch = BuiltInPatcher{ Type: "builtin", ID: "simplify-polymorphic-schemas", Description: "Merges polymorphic schemas (oneOf, anyOf, allOf) into a single schema", PatchV3DocumentFunc: MergePolymorphicSchemas, }
var PruneDocumentTagsPatch = BuiltInPatcher{ Type: "builtin", ID: "prune-document-tags", Description: "Removes all tags from the document", PatchV3DocumentFunc: PruneDocumentTags, }
var PruneInvalidPathsPatch = BuiltInPatcher{ Type: "builtin", ID: "prune-invalid-paths", Description: "Removes all paths that are invalid (e.g. empty path, path with invalid characters)", PatchV3DocumentFunc: PruneInvalidPaths, }
var PruneOperationTagsExceptFirstPatch = BuiltInPatcher{ Type: "builtin", ID: "prune-operation-tags-keep-first", Description: "Removes all tags from operations except the first one", PatchV3DocumentFunc: PruneOperationTagsExceptFirst, }
var PruneOperationTagsPatch = BuiltInPatcher{ Type: "builtin", ID: "prune-operation-tags", Description: "Removes all tags from operations", PatchV3DocumentFunc: PruneOperationTags, }
var PrunePathPrefixPatch = BuiltInPatcher{ Type: "builtin", ID: "prune-path-prefix", Description: "Prunes a prefix from all paths in the OpenAPI document", PatchV3DocumentFunc: PrunePathPrefix, }
var PruneUnusualPathsPatch = BuiltInPatcher{ Type: "builtin", ID: "prune-unusual-paths", Description: "Removes all paths that are unusual (e.g. path parameters with underscores, ...)", PatchV3DocumentFunc: PruneUnusualPaths, }
var SetEndpointPatch = BuiltInPatcher{ Type: "builtin", ID: "set-endpoint", Description: "Sets the server endpoint URL for the OpenAPI document", PatchV3DocumentFunc: SetEndpoint, }
var SetOperationTagPatch = BuiltInPatcher{ Type: "builtin", ID: "set-operation-tag", Description: "Sets a tag for all operations in the OpenAPI document", PatchV3DocumentFunc: SetOperationTag, }
var SimplifyAllOfPatch = BuiltInPatcher{ Type: "builtin", ID: "simplify-all-of", Description: "Merges allOf subschemas into the parent schema", PatchV3DocumentFunc: SimplifyAllOf, }
var SimplifyPolymorphicBooleansPatch = BuiltInPatcher{ Type: "builtin", ID: "simplify-polymorphic-booleans", Description: "Merges polymorphic boolean schemas (oneOf, anyOf, allOf) into a single boolean schema", PatchV3DocumentFunc: SimplifyPolymorphicBooleans, }
var SpeakeasyCleanupPatch = BuiltInPatcher{ Type: "speakeasy", ID: "cleanup", Description: "Cleanup the formatting of a given OpenAPI document", PatchFileFunc: SpeakeasyCleanup, }
var SpeakeasyFormatPatch = BuiltInPatcher{ Type: "speakeasy", ID: "format", Description: "Format an OpenAPI document to be more human-readable", PatchFileFunc: SpeakeasyFormat, }
var SpeakeasyNormalizePatch = BuiltInPatcher{ Type: "speakeasy", ID: "normalize", Description: "Normalize an OpenAPI document to be more human-readable", PatchFileFunc: SpeakeasyNormalize, }
var SpeakeasyRemoveUnusedPatch = BuiltInPatcher{ Type: "speakeasy", ID: "remove-unused", Description: "Given an OpenAPI file, remove all unused options", PatchFileFunc: SpeakeasyRemoveUnused, }
Functions ¶
func AddComponentSchemaPrefix ¶
func AddComponentSchemaPrefix(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func AddIdempotencyKey ¶
func AddIdempotencyKey(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
AddIdempotencyKey adds an idempotency key to all POST operations in the OpenAPI document - see https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/
func AddPathPrefix ¶
func AddPathPrefix(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func ApplyPatches ¶
func ApplyPatches(input []byte, patches []sharedpatch.SpecPatch) ([]byte, error)
func FixCommon ¶
func FixCommon(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
FixCommon fixes various common issues
func FixInvalidMaxValue ¶
func FixInvalidMaxValue(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
FixInvalidMaxValue fixes integers and longs, where the maximum value is out of bounds for the type
func FixMissingSchemaTitle ¶
func FixMissingSchemaTitle(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
FixMissingSchemaTitle fills in missing schema titles with the schema key
func FixOAS300Version ¶
func FixOAS300Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func FixOAS301Version ¶
func FixOAS301Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func FixOAS302Version ¶
func FixOAS302Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func FixOAS303Version ¶
func FixOAS303Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func FixOAS304Version ¶
func FixOAS304Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func FixOAS310Version ¶
func FixOAS310Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func FixOAS311Version ¶
func FixOAS311Version(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func FixOperationTags ¶
func FixOperationTags(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
FixOperationTags ensures all operations have tags, and that tags are documented in the document
func FixRemoveCommonOperationIdPrefix ¶
func FixRemoveCommonOperationIdPrefix(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
FixRemoveCommonOperationIdPrefix sets the operation IDs of all operations and fixes some commonly seen issues.
func FlattenComponents ¶
func FlattenComponents(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func GenerateMissingOperationIds ¶
func GenerateMissingOperationIds(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func GenerateOpenAPIOverlay ¶
func GenerateOpenAPIOverlay(doc *libopenapi.DocumentModel[v3.Document], id string) ([]byte, error)
func GenerateOperationIds ¶
func GenerateOperationIds(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func GenerateTagFromDocTitle ¶
func GenerateTagFromDocTitle(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
GenerateTagFromDocTitle removes all tags and creates one new tag per API spec doc from document title setting it on each operation. Note: This patch must be applied before merging specs.
func LLMOperationIDPatch ¶
func LLMOperationIDPatch(doc *libopenapi.DocumentModel[v3.Document]) ([]byte, error)
func MergePolymorphicProperties ¶
func MergePolymorphicProperties(v3Model *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
MergePolymorphicProperties merges polymorphic property values (anyOf, oneOf, allOf) into a single flat schema referenced by resp. properties
func MergePolymorphicSchemas ¶
func MergePolymorphicSchemas(v3Model *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
MergePolymorphicSchemas merges polymorphic schemas (anyOf, oneOf, allOf) into a single flat schema
func PruneDocumentTags ¶
func PruneDocumentTags(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func PruneInvalidPaths ¶
func PruneInvalidPaths(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func PruneOperationTags ¶
func PruneOperationTags(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func PruneOperationTagsExceptFirst ¶
func PruneOperationTagsExceptFirst(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func PrunePathPrefix ¶
func PrunePathPrefix(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func PruneUnusualPaths ¶
func PruneUnusualPaths(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func ResolvePatchSets ¶
func ResolvePatchSets(patchSets []PatchSet) []sharedpatch.SpecPatch
func SetEndpoint ¶
func SetEndpoint(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func SetOperationTag ¶
func SetOperationTag(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
func SimplifyAllOf ¶
func SimplifyAllOf(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
SimplifyAllOf merges allOf subschemas into the parent schema
func SimplifyPolymorphicBooleans ¶
func SimplifyPolymorphicBooleans(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
SimplifyPolymorphicBooleans looks for booleans defined as polymorphic types and simplifies them
func SpeakeasyCleanup ¶
func SpeakeasyFormat ¶
func SpeakeasyNormalize ¶
Types ¶
type BuiltInPatcher ¶
type BuiltInPatcher struct {
Type string `yaml:"type"`
ID string `yaml:"id,omitempty"`
Description string `yaml:"description,omitempty"`
PatchV3DocumentFunc func(doc *libopenapi.DocumentModel[v3.Document], config map[string]interface{}) error
PatchFileFunc func(inputFile string, config map[string]interface{}) ([]byte, error)
}
func (BuiltInPatcher) ToSpecPatch ¶
func (bip BuiltInPatcher) ToSpecPatch() sharedpatch.SpecPatch
type PatchPreset ¶
type PatchPreset struct {
Id string `yaml:"id"`
Patches []sharedpatch.SpecPatch `yaml:"patches"`
}