Skip to content

Commit

Permalink
refactor: format time as string
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Feb 9, 2024
1 parent 962e710 commit 7ae7bda
Show file tree
Hide file tree
Showing 21 changed files with 548 additions and 568 deletions.
14 changes: 1 addition & 13 deletions generator/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ const (
SchemaTypeNumber = "number"
// SchemaTypeBoolean represents a boolean schema type.
SchemaTypeBoolean = "boolean"
// SchemaTypeTime represents a time schema type.
SchemaTypeTime = "time"
)

// Schema represents a parsed OpenAPI schema.
Expand Down Expand Up @@ -202,14 +200,6 @@ func (s *Schema) init(doc *Doc, scope map[string]*Schema, name string) {
s.CamelName = strcase.ToCamel(s.parent.CamelName)
}

if s.Type == SchemaTypeString {
parts := strings.Split(s.name, "_")
switch parts[len(parts)-1] {
case "at", "time":
s.Type = SchemaTypeTime
}
}

if s.isArray() {
s.Items.parent = s
s.Items.required = true // a workaround to not have slices with pointers
Expand Down Expand Up @@ -283,7 +273,7 @@ func (s *Schema) isArray() bool {

func (s *Schema) isScalar() bool {
switch s.Type {
case SchemaTypeString, SchemaTypeInteger, SchemaTypeNumber, SchemaTypeBoolean, SchemaTypeTime:
case SchemaTypeString, SchemaTypeInteger, SchemaTypeNumber, SchemaTypeBoolean:
return true
}

Expand Down Expand Up @@ -325,8 +315,6 @@ func getScalarType(s *Schema) *jen.Statement {
return jen.Float64()
case SchemaTypeBoolean:
return jen.Bool()
case SchemaTypeTime:
return jen.Qual("time", "Time")
default:
panic(fmt.Errorf("unknown type %q", s.Type))
}
Expand Down
57 changes: 28 additions & 29 deletions handler/account/account.go

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

35 changes: 22 additions & 13 deletions handler/accountauthentication/accountauthentication.go

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

45 changes: 22 additions & 23 deletions handler/accountteam/accountteam.go

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

Loading

0 comments on commit 7ae7bda

Please sign in to comment.