Skip to content

Commit fa6150f

Browse files
committed
improve api, comments and readme
1 parent e768d73 commit fa6150f

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,10 @@ Other supported options are:
6666
* `use_ref`
6767
* when set to `true`, the output uses the `$ref` field in OpenAPI spec to reference other schemas.
6868
* `yaml`
69-
* when set to `true`, the output is in yaml file.
69+
* when set to `true`, the output is in yaml file.
70+
* `include_description`
71+
* when set to `true`, the openapi schema will include descriptions, generated from the proto message comment.
72+
* `enum_as_int_or_string`
73+
* when set to `true`, the openapi schema will include `x-kubernetes-int-or-string` on enums.
74+
* `additional_empty_schemas`
75+
* a `+` separated list of message names (`core.solo.io.Status`), whose generated schema should be an empty object that accepts all values.

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func generate(request plugin.CodeGeneratorRequest) (*plugin.CodeGeneratorRespons
104104
default:
105105
return nil, fmt.Errorf("unknown value '%s' for enum_as_int_or_string", v)
106106
}
107-
} else if k == "empty_schema" {
107+
} else if k == "additional_empty_schema" {
108108
messagesWithEmptySchema = strings.Split(v, "+")
109109
} else {
110110
return nil, fmt.Errorf("unknown argument '%s' specified", k)

openapiGenerator.go

+5
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ func newOpenAPIGenerator(
130130
}
131131
}
132132

133+
// buildCustomSchemasByMessageName name returns a mapping of message name to a pre-defined openapi schema
134+
// It includes:
135+
// 1. `specialSoloTypes`, a set of pre-defined schemas
136+
// 2. `messagesWithEmptySchema`, a list of messages that are injected at runtime that should contain
137+
// and empty schema which accepts and preserves all fields
133138
func buildCustomSchemasByMessageName(messagesWithEmptySchema []string) map[string]openapi3.Schema {
134139
schemasByMessageName := make(map[string]openapi3.Schema)
135140

0 commit comments

Comments
 (0)