Documentation
¶
Overview ¶
Package codegen provides the public API for oapi-codegen's experimental code generator.
This package re-exports the core types and functions from the internal implementation, providing a stable public interface for external consumers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
func Generate(doc libopenapi.Document, specData []byte, cfg Configuration) (string, error)
Generate produces Go code from the parsed OpenAPI document. specData is the raw spec bytes used to embed the spec in the generated code.
Types ¶
type Configuration ¶
type Configuration = impl.Configuration
Configuration is the top-level configuration for code generation.
type GenerationOptions ¶
type GenerationOptions = impl.GenerationOptions
GenerationOptions controls which parts of the code are generated.
type ModelsPackage ¶
type ModelsPackage = impl.ModelsPackage
ModelsPackage specifies an external package containing the model types.
type NameMangling ¶
type NameMangling = impl.NameMangling
NameMangling configures how OpenAPI names are converted to Go identifiers.
type NameSubstitutions ¶
type NameSubstitutions = impl.NameSubstitutions
NameSubstitutions allows direct overrides of generated names.
type OutputOptions ¶
type OutputOptions = impl.OutputOptions
OutputOptions controls filtering of operations and schemas.
type RuntimeOutput ¶
type RuntimeOutput = impl.RuntimeOutput
RuntimeOutput holds the generated code for each runtime sub-package.
func GenerateRuntime ¶
func GenerateRuntime(baseImportPath string) (*RuntimeOutput, error)
GenerateRuntime produces standalone Go source files for each of the three runtime sub-packages (types, params, helpers). baseImportPath is the base import path for the runtime module (e.g., "github.com/org/project/runtime").
type RuntimePackageConfig ¶
type RuntimePackageConfig = impl.RuntimePackageConfig
RuntimePackageConfig specifies an external package containing runtime helpers.
type StructTagsConfig ¶
type StructTagsConfig = impl.StructTagsConfig
StructTagsConfig configures how struct tags are generated for fields.
type TypeMapping ¶
type TypeMapping = impl.TypeMapping
TypeMapping allows customizing OpenAPI type/format to Go type mappings.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codegen generates Go code from parsed OpenAPI specs.
|
Package codegen generates Go code from parsed OpenAPI specs. |
|
templates/test/helpers/genhelpers
command
genhelpers generates Go files from helper and param templates.
|
genhelpers generates Go files from helper and param templates. |
|
templates/test/types/gentypes
command
gentypes generates Go type files from templates.
|
gentypes generates Go type files from templates. |
|
test/name_conflict_resolution
Package name_conflict_resolution tests comprehensive type name collision resolution.
|
Package name_conflict_resolution tests comprehensive type name collision resolution. |
|
test/previous_version/all_of
Package all_of tests allOf schema composition from the V2 test suite.
|
Package all_of tests allOf schema composition from the V2 test suite. |
|
test/previous_version/any_of/inline
Package inline tests inline anyOf schema composition from the V2 test suite.
|
Package inline tests inline anyOf schema composition from the V2 test suite. |
|
test/previous_version/any_of/param
Package param tests anyOf/oneOf in parameters from the V2 test suite.
|
Package param tests anyOf/oneOf in parameters from the V2 test suite. |
|
test/previous_version/components
Package components tests complex component schemas from the V2 test suite.
|
Package components tests complex component schemas from the V2 test suite. |
|
test/previous_version/extensions/x_order
Package x_order tests x-order field ordering extension from the V2 test suite.
|
Package x_order tests x-order field ordering extension from the V2 test suite. |
|
test/previous_version/issues/issue_1029
Package issue_1029 tests that oneOf with multiple single-value string enums generates valid code.
|
Package issue_1029 tests that oneOf with multiple single-value string enums generates valid code. |
|
test/previous_version/issues/issue_1039
Package issue_1039 tests nullable type generation.
|
Package issue_1039 tests nullable type generation. |
|
test/previous_version/issues/issue_1087
Package issue_1087 tests external dependencies with import resolution.
|
Package issue_1087 tests external dependencies with import resolution. |
|
test/previous_version/issues/issue_1087/deps
Package deps provides external dependency types for issue 1087.
|
Package deps provides external dependency types for issue 1087. |
|
test/previous_version/issues/issue_1093
Package issue_1093 tests multi-spec cross-package imports.
|
Package issue_1093 tests multi-spec cross-package imports. |
|
test/previous_version/issues/issue_1127
Package issue_1127 tests multiple content types.
|
Package issue_1127 tests multiple content types. |
|
test/previous_version/issues/issue_1168
Package issue_1168 tests additionalProperties: true.
|
Package issue_1168 tests additionalProperties: true. |
|
test/previous_version/issues/issue_1180
Package issue_1180 tests parameter style handling.
|
Package issue_1180 tests parameter style handling. |
|
test/previous_version/issues/issue_1182
Package issue_1182 tests external response refs across specs.
|
Package issue_1182 tests external response refs across specs. |
|
test/previous_version/issues/issue_1189
Package issue_1189 tests anyOf/allOf/oneOf composition.
|
Package issue_1189 tests anyOf/allOf/oneOf composition. |
|
test/previous_version/issues/issue_1208_1209
Package issue_1208_1209 tests multiple JSON content types.
|
Package issue_1208_1209 tests multiple JSON content types. |
|
test/previous_version/issues/issue_1212
Package issue_1212 tests multi-package response schemas.
|
Package issue_1212 tests multi-package response schemas. |
|
test/previous_version/issues/issue_1219
Package issue_1219 tests additionalProperties merge with allOf.
|
Package issue_1219 tests additionalProperties merge with allOf. |
|
test/previous_version/issues/issue_1298
Package issue_1298 tests custom content-type schemas.
|
Package issue_1298 tests custom content-type schemas. |
|
test/previous_version/issues/issue_1397
Package issue_1397 tests basic type generation with x-go-type-name.
|
Package issue_1397 tests basic type generation with x-go-type-name. |
|
test/previous_version/issues/issue_1429
Package issue_1429 tests that enums inside anyOf members are generated.
|
Package issue_1429 tests that enums inside anyOf members are generated. |
|
test/previous_version/issues/issue_1496
Package issue_1496 tests that inline schemas generate valid Go identifiers.
|
Package issue_1496 tests that inline schemas generate valid Go identifiers. |
|
test/previous_version/issues/issue_1561
Package issue_1561 tests skip-optional-pointer on containers.
|
Package issue_1561 tests skip-optional-pointer on containers. |
|
test/previous_version/issues/issue_1710
Package issue_1710 tests that fields are not lost in nested allOf oneOf structures.
|
Package issue_1710 tests that fields are not lost in nested allOf oneOf structures. |
|
test/previous_version/issues/issue_1767
Package issue_1767 tests underscore field name mapping.
|
Package issue_1767 tests underscore field name mapping. |
|
test/previous_version/issues/issue_1825
Package issue_1825 tests overlay and external refs.
|
Package issue_1825 tests overlay and external refs. |
|
test/previous_version/issues/issue_193
Package issue_193 tests allOf with additionalProperties merging.
|
Package issue_193 tests allOf with additionalProperties merging. |
|
test/previous_version/issues/issue_1957
Package issue_1957 tests x-go-type with skip-optional-pointer.
|
Package issue_1957 tests x-go-type with skip-optional-pointer. |
|
test/previous_version/issues/issue_2031
Package issue_2031 tests skip-optional-pointer with arrays.
|
Package issue_2031 tests skip-optional-pointer with arrays. |
|
test/previous_version/issues/issue_2102
Package issue_2102 tests that properties defined at the same level as allOf are included.
|
Package issue_2102 tests that properties defined at the same level as allOf are included. |
|
test/previous_version/issues/issue_240
Package issue_240 tests models with no type field.
|
Package issue_240 tests models with no type field. |
|
test/previous_version/issues/issue_312
Package issue_312 tests proper escaping of paths with special characters.
|
Package issue_312 tests proper escaping of paths with special characters. |
|
test/previous_version/issues/issue_502
Package issue_502 tests that anyOf with only one ref generates the referenced type.
|
Package issue_502 tests that anyOf with only one ref generates the referenced type. |
|
test/previous_version/issues/issue_52
Package issue_52 tests that recursive types are handled properly.
|
Package issue_52 tests that recursive types are handled properly. |
|
test/previous_version/issues/issue_579
Package issue_579 tests aliased types with date format.
|
Package issue_579 tests aliased types with date format. |
|
test/previous_version/issues/issue_609
Package issue_609 tests optional field with no type info.
|
Package issue_609 tests optional field with no type info. |
|
test/previous_version/issues/issue_697
Package issue_697 tests that properties alongside allOf are included.
|
Package issue_697 tests that properties alongside allOf are included. |
|
test/previous_version/issues/issue_775
Package issue_775 tests that allOf with format specification works correctly.
|
Package issue_775 tests that allOf with format specification works correctly. |
|
test/previous_version/issues/issue_832
Package issue_832 tests x-go-type-name override for enum types.
|
Package issue_832 tests x-go-type-name override for enum types. |
|
test/previous_version/issues/issue_936
Package issue_936 tests recursive/circular schema references.
|
Package issue_936 tests recursive/circular schema references. |
|
test/previous_version/issues/issue_head_digit_operation_id
Package issue_head_digit_operation_id tests operation IDs starting with digits.
|
Package issue_head_digit_operation_id tests operation IDs starting with digits. |
|
test/previous_version/issues/issue_illegal_enum_names
Package issue_illegal_enum_names tests enum constant generation with edge cases.
|
Package issue_illegal_enum_names tests enum constant generation with edge cases. |
|
test/previous_version/issues/issue_removed_external_ref
Package issue_removed_external_ref tests external ref filtering.
|
Package issue_removed_external_ref tests external ref filtering. |
|
test/previous_version/outputoptions/name_normalizer
Package name_normalizer tests name normalization from the V2 test suite.
|
Package name_normalizer tests name normalization from the V2 test suite. |
|
test/previous_version/parameters
Package parameters tests parameter type generation from the V2 test suite.
|
Package parameters tests parameter type generation from the V2 test suite. |
|
test/previous_version/schemas
Package schemas tests comprehensive schema generation from the V2 test suite.
|
Package schemas tests comprehensive schema generation from the V2 test suite. |