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

optionally include descriptions in schema #585

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/v0.41.1/exclude-descriptions-in-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: NON_USER_FACING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i think this could be NEW_FEATURE although i don't know if we publish the skv2 changelogs anywhere so this is probably fine

issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/18562
description: >
Add option to exclude descriptions in schema.
skipCI: "false"
5 changes: 3 additions & 2 deletions codegen/collector/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type OpenApiProtocExecutor struct {
OutputDir string

// Whether to include descriptions in validation schemas
IncludeDescriptionsInSchema bool
ExcludeDescriptionsInSchema bool

// Whether to assign Enum fields the `x-kubernetes-int-or-string` property
// which allows the value to either be an integer or a string
Expand Down Expand Up @@ -108,11 +108,12 @@ func (o *OpenApiProtocExecutor) Execute(protoFile string, toFile string, imports
_, fileName := filepath.Split(protoFile)
directoryName := fileName[0 : len(fileName)-len(filepath.Ext(fileName))]

baseArgument := "--openapi_out=yaml=true,single_file=false,include_description=true,multiline_description=true,proto_oneof=true,int_native=true"
baseArgument := "--openapi_out=yaml=true,single_file=false,multiline_description=true,proto_oneof=true,int_native=true"
baseArgument = fmt.Sprintf("%s,enum_as_int_or_string=%v", baseArgument, o.EnumAsIntOrString)
baseArgument = fmt.Sprintf("%s,additional_empty_schema=%v", baseArgument, strings.Join(o.MessagesWithEmptySchema, "+"))
baseArgument = fmt.Sprintf("%s,disable_kube_markers=%v", baseArgument, o.DisableKubeMarkers)
baseArgument = fmt.Sprintf("%s,ignored_kube_marker_substrings=%v", baseArgument, strings.Join(o.IgnoredKubeMarkerSubstrings, "+"))
baseArgument = fmt.Sprintf("%s,include_description=%v", baseArgument, !o.ExcludeDescriptionsInSchema)

// Create the directory
directoryPath := filepath.Join(o.OutputDir, directoryName)
Expand Down
3 changes: 3 additions & 0 deletions codegen/proto/schemagen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const (
)

type ValidationSchemaOptions struct {
// Whether to include descriptions in validation schemas
ExcludeDescriptionsInSchema bool

// Whether to assign Enum fields the `x-kubernetes-int-or-string` property
// which allows the value to either be an integer or a string
// If this is false, only string values are allowed
Expand Down
1 change: 1 addition & 0 deletions codegen/proto/schemagen/protoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (p *protocGenerator) GetJSONSchemas(protoFiles []string, imports []string,
EnumAsIntOrString: p.validationSchemaOptions.EnumAsIntOrString,
MessagesWithEmptySchema: p.validationSchemaOptions.MessagesWithEmptySchema,
DisableKubeMarkers: p.validationSchemaOptions.DisableKubeMarkers,
ExcludeDescriptionsInSchema: p.validationSchemaOptions.ExcludeDescriptionsInSchema,
IgnoredKubeMarkerSubstrings: p.validationSchemaOptions.IgnoredKubeMarkerSubstrings,
}

Expand Down
Loading