OpenAPI: add required section for the non-nullable columns (#1148)

This commit is contained in:
Alexey Alekhin
2018-07-23 11:11:45 -05:00
committed by Steve Chávez
parent fa1e92fdf2
commit 2b46afe1ec
3 changed files with 7 additions and 2 deletions
+1
View File
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #1099, Add support for getting json/jsonb by array index - @steve-chavez
- #1145, Add materialized view columns to OpenAPI output - @steve-chavez
- #709, Allow embedding on views with subselects/CTE - @steve-chavez
- #1148, OpenAPI: add `required` section for the non-nullable columns - @laughedelic
### Fixed
+2 -1
View File
@@ -42,7 +42,8 @@ makeTableDef pks (t, cs, _) =
(tn, (mempty :: Schema)
& description .~ tableDescription t
& type_ .~ SwaggerObject
& properties .~ fromList (map (makeProperty pks) cs))
& properties .~ fromList (map (makeProperty pks) cs)
& required .~ map colName (filter (not . colNullable) cs))
makeProperty :: [PrimaryKey] -> Column -> (Text, Referenced Schema)
makeProperty pks c = (colName c, Inline s)
+4 -1
View File
@@ -113,7 +113,10 @@ spec = do
"format": "integer",
"type": "integer"
}
}
},
"required": [
"id"
]
}
|]