You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
REST APIs come in many flavours, some not always purely RESTful. It would be helpful if schemas for rom-http relations could support optional attributes. This is for a scenario where an API provides a limited set of attributes from a search or collection API endpoint. Then the full details of the resource must be retrieved from a REST endpoint that represents that resource.
The specific example that triggered this is using rom-http with the Spoonacular API. This has a "Search Recipes" endpoint that returns recipes with about 8 attributes, then the "Get Recipe Information" endpoint returns a full recipe object with much more data.
NOTE: Some attributes are camelCase because currently I'm not sure of the best approach to map them to ruby snake case. If there is a known pattern for this, tips welcome :)
@flash-gordon 👋🏻 just wanted to double-check with you - this makes perfect sense, right? We could follow the same convention as you introduced in dry-struct, so just adding attribute? and handle it as expected would do the trick. WDYT?
@solnic / @flash-gordon, I wanted to check in on this. I'm running into a similar issue (where the APII am integrating with does not always return the full set of possible params on all requests to the same resource). dry-initializer and dry-schema support something similar to this already, I can work on a PR if this is still a possibility.
As a somewhat philosophical point, since external API schemas are out of the control of the API wrapper library, it might make more sense if all attributes were assumed optional, or at least if there could be a ROM config to set this.
REST APIs come in many flavours, some not always purely RESTful. It would be helpful if schemas for rom-http relations could support optional attributes. This is for a scenario where an API provides a limited set of attributes from a search or collection API endpoint. Then the full details of the resource must be retrieved from a REST endpoint that represents that resource.
The specific example that triggered this is using rom-http with the Spoonacular API. This has a "Search Recipes" endpoint that returns recipes with about 8 attributes, then the "Get Recipe Information" endpoint returns a full recipe object with much more data.
Examples
This might look like:
NOTE: Some attributes are camelCase because currently I'm not sure of the best approach to map them to ruby snake case. If there is a known pattern for this, tips welcome :)
Resources
First queried here.
The text was updated successfully, but these errors were encountered: