Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make external ref internalization optional #840

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/codegen/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type OutputOptions struct {
ExcludeSchemas []string `yaml:"exclude-schemas,omitempty"` // Exclude from generation schemas with given names. Ignored when empty.
ResponseTypeSuffix string `yaml:"response-type-suffix,omitempty"` // The suffix used for responses types
ClientTypeName string `yaml:"client-type-name,omitempty"` // Override the default generated client type with the value
InternalizeRefs bool `yaml:"internalize-refs,omitempty"` // Internalize external $ref types
}

// UpdateDefaults sets reasonable default values for unset fields in Configuration
Expand Down
4 changes: 3 additions & 1 deletion pkg/codegen/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import (
// swagger definition, which we embed inside the generated code.
func GenerateInlinedSpec(t *template.Template, importMapping importMap, swagger *openapi3.T) (string, error) {
// ensure that any external file references are embedded into the embedded spec
swagger.InternalizeRefs(context.Background(), nil)
if globalState.OutputOptions.InternalizeRefs {
swagger.InternalizeRefs(context.Background(), openapi3.DefaultRefNameResolver)
}
// Marshal to json
encoded, err := swagger.MarshalJSON()
if err != nil {
Expand Down