Repository navigation
Expand file tree
/
Copy pathcodegen.go
More file actions
54 lines (40 loc) · 2.12 KB
/
Copy pathcodegen.go
File metadata and controls
54 lines (40 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 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.
package codegen
import (
"github.com/pb33f/libopenapi"
impl "github.com/oapi-codegen/oapi-codegen-exp/codegen/internal"
)
// Configuration is the top-level configuration for code generation.
type Configuration = impl.Configuration
// GenerationOptions controls which parts of the code are generated.
type GenerationOptions = impl.GenerationOptions
// OutputOptions controls filtering of operations and schemas.
type OutputOptions = impl.OutputOptions
// ModelsPackage specifies an external package containing the model types.
type ModelsPackage = impl.ModelsPackage
// TypeMapping allows customizing OpenAPI type/format to Go type mappings.
type TypeMapping = impl.TypeMapping
// NameMangling configures how OpenAPI names are converted to Go identifiers.
type NameMangling = impl.NameMangling
// NameSubstitutions allows direct overrides of generated names.
type NameSubstitutions = impl.NameSubstitutions
// StructTagsConfig configures how struct tags are generated for fields.
type StructTagsConfig = impl.StructTagsConfig
// RuntimePackageConfig specifies an external package containing runtime helpers.
type RuntimePackageConfig = impl.RuntimePackageConfig
// RuntimeOutput holds the generated code for each runtime sub-package.
type RuntimeOutput = impl.RuntimeOutput
// Generate produces Go code from the parsed OpenAPI document.
// specData is the raw spec bytes used to embed the spec in the generated code.
func Generate(doc libopenapi.Document, specData []byte, cfg Configuration) (string, error) {
return impl.Generate(doc, specData, cfg)
}
// 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").
func GenerateRuntime(baseImportPath string) (*RuntimeOutput, error) {
return impl.GenerateRuntime(baseImportPath)
}