👋 Hi there, thanks for creating this project!
In using the spec to generate models, I've noticed that many properties that are guaranteed by the Hue API docs are not marked as required in the openhue schemas.
For example, going by the RoomGet docs, I would expect to have a final type like this in Rust:
pub struct RoomGet {
pub r#type: String,
pub id: String,
// this is the only property not labeled as `required` by the Hue docs
pub id_v1: Option<String>,
pub children: Vec<models::ResourceIdentifier>,
pub services: Vec<models::ResourceIdentifier>,
pub metadata: models::RoomGetMetadata,
}
...but because no properties are required in the schema, I end up with this instead:
pub struct RoomGet {
pub r#type: Option<String>,
pub id: Option<String>,
pub id_v1: Option<String>,
pub children: Option<Vec<models::ResourceIdentifier>>,
pub services: Option<Vec<models::ResourceIdentifier>>,
pub metadata: Option<models::RoomGetMetadata>,
}
This leads to the generated models being somewhat clunky to use. If I have a RoomGet struct from an API response, I have to perform extra error-handling in order to use $room.id because the type definition says it might be null.
At a glance it's not clear to me how quick and/or easy this is to address. Changing anything at all requires manual cross-checking against the Hue API docs, and changing shared schemas (i.e. Resource) needs to be done with care. Also it's occurring to me that changing properties from non-required to required could be considered a breaking change by consumers of the spec (?).
Anyhow, let me know your thoughts. If it's something you want to change I'm happy to help contribute.
👋 Hi there, thanks for creating this project!
In using the spec to generate models, I've noticed that many properties that are guaranteed by the Hue API docs are not marked as
requiredin the openhue schemas.For example, going by the
RoomGetdocs, I would expect to have a final type like this in Rust:...but because no properties are
requiredin the schema, I end up with this instead:This leads to the generated models being somewhat clunky to use. If I have a
RoomGetstruct from an API response, I have to perform extra error-handling in order to use$room.idbecause the type definition says it might be null.At a glance it's not clear to me how quick and/or easy this is to address. Changing anything at all requires manual cross-checking against the Hue API docs, and changing shared schemas (i.e.
Resource) needs to be done with care. Also it's occurring to me that changing properties from non-required to required could be considered a breaking change by consumers of the spec (?).Anyhow, let me know your thoughts. If it's something you want to change I'm happy to help contribute.