typegen: add schema generation#22
Conversation
| "ref": "ExampleDirection" | ||
| }, | ||
| "items": { | ||
| "elements": {} |
There was a problem hiding this comment.
Running go generate ./example results in modification in this file:
@@ -35,7 +35,9 @@ ExampleEchoRequest: {
"ref": "ExampleDirection"
},
"items": {
- "elements": {}
+ "elements": {
+ "ref": "ExampleCustomType2"
+ }
},
"maps": {
"values": {| }, | ||
| }).Parse(GlobalSchemaTemplate) | ||
| panicIf(err) | ||
| tmpl.Execute(writer, map[string]interface{}{ |
There was a problem hiding this comment.
golangci-lint: Error return value of tmpl.Execute is not checked
| } | ||
| switch { | ||
| case k == reflect.Ptr: | ||
| t = indirect(t) |
There was a problem hiding this comment.
golangci-lint: this value of t is never used
| _ = os.RemoveAll(filepath.Join(options.OutDir, "schema.ts")) | ||
| schemaFile, _ := os.OpenFile(filepath.Join(options.OutDir, "schema.ts"), os.O_WRONLY|os.O_CREATE, 0755) | ||
| _ = typegen.PrintJDT(parser, schemaFile) |
| } | ||
| return "" | ||
| } | ||
| func SerializeCustomSchema(t reflect.Type) string { |
There was a problem hiding this comment.
How is this function used? I don't see any usage in api2 itself.
| return nil | ||
| } | ||
|
|
||
| func ToSchema(schema *JSONTypeDefSchema) (*jdt.Schema, error) { |
There was a problem hiding this comment.
How is this function used? I don't see any usage in api2 itself.
| type JSONTypeDefSchema struct { | ||
| Definitions map[string]JSONTypeDefSchema `json:"definitions,omitempty"` | ||
| Metadata map[string]interface{} `json:"metadata,omitempty"` | ||
| Nullable bool `json:"nullable,omitempty"` |
There was a problem hiding this comment.
IMHO, bool type should not have omitempty.
| Metadata map[string]interface{} `json:"metadata,omitempty"` | ||
| Nullable bool `json:"nullable,omitempty"` | ||
| Ref *string `json:"ref,omitempty"` | ||
| Type jdt.Type `json:"type,omitempty"` |
There was a problem hiding this comment.
IMHO, jdt.Type (string) type should not have omitempty.
| Elements *JSONTypeDefSchema `json:"elements,omitempty"` | ||
| Properties map[string]JSONTypeDefSchema `json:"properties,omitempty"` | ||
| OptionalProperties map[string]JSONTypeDefSchema `json:"optionalProperties,omitempty"` | ||
| AdditionalProperties bool `json:"additionalProperties,omitempty"` |
There was a problem hiding this comment.
IMHO, bool type should not have omitempty.
| OptionalProperties map[string]JSONTypeDefSchema `json:"optionalProperties,omitempty"` | ||
| AdditionalProperties bool `json:"additionalProperties,omitempty"` | ||
| Values *JSONTypeDefSchema `json:"values,omitempty"` | ||
| Discriminator string `json:"discriminator,omitempty"` |
There was a problem hiding this comment.
IMHO, string type should not have omitempty.
No description provided.