Openapi: we need an Array and fields contract. #568
Replies: 4 comments 3 replies
-
We can certainly emit empty arrays when there's no data, instead of skipping the field. |
Beta Was this translation helpful? Give feedback.
-
I don't think we ever have |
Beta Was this translation helpful? Give feedback.
-
Just to be clear. Skipped: {} Null: {
"items": null,
} Empty: {
"items": [],
} |
Beta Was this translation helpful? Give feedback.
-
Perhaps I shouldn't have used the word "null" as it is a particular thing of a language. Sorry for that. My main point is:
trustify/modules/fundamental/src/vulnerability/model/mod.rs Lines 21 to 22 in ea568e0 trustify/modules/importer/src/model/sbom.rs Lines 11 to 12 in ea568e0
My original intention is to avoid issues like the one reported here trustification/trustify-ui#114 . |
Beta Was this translation helpful? Give feedback.
-
The REST Endpoints are growing and we need a formal contract between server and client. Without it the client never knows what to expect from the backend.
Arrays
It has been mentioned in some discussions that fields whose type is an array should never been NULL but rather an empty array or an array with values.
What is our position on this? I personally suggest having an empty array rather than NULL
Fields
Let's use the Openapi definition to know which fields are mandatory and which ones are optional (nullable). When using Swagger the mandatory fields always have a red cross next to the field name.
I suggest appropriately using this as it would simplistic to mask every field as optional and avoid having a proper design.
Beta Was this translation helpful? Give feedback.
All reactions