Skip to content

Commit

Permalink
Merge pull request #310 from tdakkota/fix/variants-naming
Browse files Browse the repository at this point in the history
fix(gen): null variant naming
  • Loading branch information
ernado authored Apr 25, 2022
2 parents 3a42786 + 5318cb4 commit 5ea7b4a
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 68 deletions.
4 changes: 2 additions & 2 deletions examples/ex_test_format/oas_client_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions examples/ex_test_format/oas_faker_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions examples/ex_test_format/oas_json_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/ex_test_format/oas_req_dec_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/ex_test_format/oas_req_enc_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 29 additions & 29 deletions examples/ex_test_format/oas_schemas_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/ex_test_format/oas_server_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/ex_test_format/oas_unimplemented_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions gen/ir/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ func (t *Type) Go() string {
func (t *Type) NamePostfix() string {
switch t.Kind {
case KindPrimitive:
if t.Primitive == Null {
return "Null"
}
switch t.Schema.Format {
case "uuid":
return "UUID"
Expand Down
2 changes: 2 additions & 0 deletions gen/schema_gen_sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func (g *schemaGen) collectSumVariants(
parent *jsonschema.Schema,
schemas []*jsonschema.Schema,
) (sum []*ir.Type, _ error) {
// TODO(tdakkota): convert oneOf+null into generic

names := map[string]struct{}{}
for i, s := range schemas {
if ref := s.Ref; ref != "" && ref == parent.Ref {
Expand Down
2 changes: 1 addition & 1 deletion gen/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (w *writer) Generate(templateName, fileName string, cfg TemplateConfig) err

b, err := imports.Process(fileName, w.buf.Bytes(), nil)
if err != nil {
_ = os.WriteFile(fileName+".dump", b, 0o600)
_ = os.WriteFile(fileName+".dump", w.buf.Bytes(), 0o600)
return errors.Wrap(err, "format imports")
}

Expand Down

0 comments on commit 5ea7b4a

Please sign in to comment.