-
Notifications
You must be signed in to change notification settings - Fork 5
16 findHWReservationById API response schema patch #52
Conversation
"customdata": { | ||
"description": "Customdata is an arbitrary JSON value that can be accessed via the\nmetadata service.", | ||
- "default": {} | ||
+ "default": null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backend allows for this field to be submitted as a JSON string ("customdata": "{\"foo\": \"bar\"}"
) or as an object ("customdata": {"foo":"bar"}
).
When omitted in the request, the default value in the response is : {}
(an empty object).
My inclination here would be to represent the field as an object with default {}
. Is the problem that type: object
and additionalProperties
(https://swagger.io/docs/specification/data-models/dictionaries/#free-form) was not included in the OAS3 spec?
+ "default": null | |
"default": {}, | |
"type": "object", | |
"additionalProperties": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backend allows for this field to be submitted as a JSON string (
"customdata": "{\"foo\": \"bar\"}"
) or as an object ("customdata": {"foo":"bar"}
).
So with this change, customdata will have one string key "{\"foo\": \"bar\"}"
mapped to null
or an empty string ""
mapped to {"foo":"bar"}
after deserialization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
customdata
is the key to an arbitrary value. You may submit a string, null, a boolean, or an object here.
However, if the request looks like quoted JSON, it will be parsed. See the "serialized in" columns of this table: equinixmetal-archive/packngo#225 (comment)
This is why I believe the best OAS3 approach will be additionalProperties: true
, with type: object
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, incorporated suggestion in 2587209
@@ -7741,7 +7741,7 @@ | |||
"content": { | |||
"application/json": { | |||
"schema": { | |||
"$ref": "#/components/schemas/Device" | |||
"$ref": "#/components/schemas/HardwareReservation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃 Nice find.
Thanks, @rinzler-17. I'll start the process of upstreaming this spec change. |
Addresses #51
Description
Following schema worked with the previous version of openapi-generator:
When autocommit bumped the generator version to
6.3.0-SNAPSHOT
, oas build errored which has been fixed with"default": null
.Also, response schema of
findHardwareReservationById
has been changed FromDevice
toHardwareReservation
.