Skip to content

Commit

Permalink
Merge pull request #140 from wepala/feature/WEOS-1382
Browse files Browse the repository at this point in the history
feature: WEOS-1382 As a developer I should be able to set the type of id that I want auto generated
  • Loading branch information
akeemphilbert committed Mar 16, 2022
2 parents 98e1de3 + 5da3f2b commit 9f1fe15
Show file tree
Hide file tree
Showing 17 changed files with 1,323 additions and 1,157 deletions.
5 changes: 2 additions & 3 deletions api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ components:
type: object
properties:
id:
type: string
format: ksuid
type: integer
format: uint
firstName:
type: string
lastName:
Expand All @@ -60,7 +60,6 @@ components:
- lastName
x-identifier:
- id
- email
Blog:
type: object
properties:
Expand Down
19 changes: 14 additions & 5 deletions controllers/rest/fixtures/blog-x-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ components:
Category:
type: object
properties:
title:
id:
type: string
format: uuid
description:
type: string
required:
- title
- id
x-identifier:
- title
- id
Author:
type: object
properties:
Expand All @@ -58,7 +59,6 @@ components:
- lastName
x-identifier:
- id
- email
Blog:
type: object
properties:
Expand Down Expand Up @@ -115,6 +115,15 @@ components:
created:
type: string
format: date-time
Archives:
type: object
properties:
id:
type: integer
title:
type: string
x-identifier:
- id
paths:
/health:
summary: Health Check
Expand Down Expand Up @@ -605,4 +614,4 @@ paths:
summary: Delete author
responses:
200:
description: Delete author
description: Delete author
17 changes: 14 additions & 3 deletions controllers/rest/middleware_initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func newSchema(ref *openapi3.Schema, logger echo.Logger) (ds.Builder, map[string
relations[name] = strings.TrimPrefix(p.Ref, "#/components/schemas/")
} else {
t := p.Value.Type
f := p.Value.Format
if strings.EqualFold(t, "array") {
t2 := p.Value.Items.Value.Type
if t2 != "object" {
Expand All @@ -133,7 +134,12 @@ func newSchema(ref *openapi3.Schema, logger echo.Logger) (ds.Builder, map[string
} else if t2 == "number" {
instance.AddField(name, []float64{}, tagString)
} else if t == "integer" {
instance.AddField(name, []int{}, tagString)
if f == "uint" {
instance.AddField(name, []uint{}, tagString)
} else {
instance.AddField(name, []int{}, tagString)
}

} else if t == "boolean" {
instance.AddField(name, []bool{}, tagString)
}
Expand Down Expand Up @@ -166,8 +172,13 @@ func newSchema(ref *openapi3.Schema, logger echo.Logger) (ds.Builder, map[string
var numbers *float32
defaultValue = numbers
case "integer":
var integers *int
defaultValue = integers
if f == "uint" {
defaultValue = uint(0)
} else {
var integers *int
defaultValue = integers
}

case "boolean":
var boolean *bool
defaultValue = boolean
Expand Down
Loading

0 comments on commit 9f1fe15

Please sign in to comment.