Skip to content

Commit

Permalink
entoas: handle nillable fields (#423)
Browse files Browse the repository at this point in the history
* entoas: handle nillable fields

* go mod tidy

* go generate
  • Loading branch information
masseelch authored Jan 2, 2023
1 parent 7ed77ac commit 9abfc72
Show file tree
Hide file tree
Showing 15 changed files with 1,058 additions and 202 deletions.
2 changes: 1 addition & 1 deletion entoas/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func addSchemaFields(s *ogen.Schema, fs []*gen.Field) error {
if err != nil {
return err
}
addProperty(s, p, !f.Optional)
addProperty(s, p, !(f.Optional || f.Nillable))
}
return nil
}
Expand Down
32 changes: 16 additions & 16 deletions entoas/internal/cycle/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@
"name": "id",
"in": "path",
"description": "ID of the User",
"required": true,
"schema": {
"type": "integer"
},
"required": true
}
}
],
"responses": {
Expand Down Expand Up @@ -186,10 +186,10 @@
"name": "id",
"in": "path",
"description": "ID of the User",
"required": true,
"schema": {
"type": "integer"
},
"required": true
}
}
],
"responses": {
Expand Down Expand Up @@ -222,10 +222,10 @@
"name": "id",
"in": "path",
"description": "ID of the User",
"required": true,
"schema": {
"type": "integer"
},
"required": true
}
}
],
"requestBody": {
Expand Down Expand Up @@ -307,10 +307,10 @@
"name": "id",
"in": "path",
"description": "ID of the User",
"required": true,
"schema": {
"type": "integer"
},
"required": true
}
},
{
"name": "page",
Expand Down Expand Up @@ -371,10 +371,10 @@
"name": "id",
"in": "path",
"description": "ID of the User",
"required": true,
"schema": {
"type": "integer"
},
"required": true
}
},
{
"name": "page",
Expand Down Expand Up @@ -435,10 +435,10 @@
"name": "id",
"in": "path",
"description": "ID of the User",
"required": true,
"schema": {
"type": "integer"
},
"required": true
}
},
{
"name": "page",
Expand Down Expand Up @@ -499,10 +499,10 @@
"name": "id",
"in": "path",
"description": "ID of the User",
"required": true,
"schema": {
"type": "integer"
},
"required": true
}
},
{
"name": "page",
Expand Down Expand Up @@ -563,10 +563,10 @@
"name": "id",
"in": "path",
"description": "ID of the User",
"required": true,
"schema": {
"type": "integer"
},
"required": true
}
}
],
"responses": {
Expand Down
3 changes: 3 additions & 0 deletions entoas/internal/oastypes/migrate/schema.go

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

Loading

0 comments on commit 9abfc72

Please sign in to comment.