anyOf, allOf, etc. in /info/{entry_type} endpoints #775
Labels
bug
Something isn't working
models
For issues related to the pydantic models directly
priority/medium
Issue or PR with a consensus of medium priority
It seems via sheer luck this has not broken in the current implementation.
The use of
retrieve_queryable_properties()
breaks if any of the attributes/properties are subclasses ofpydantic.BaseModel
or is an enumeration.Since this function is only used for
/info/structures
and/info/references
and neither ofStructureResourceAttributes
andReferenceResourceAttributes
have attributes with types ofBaseModel
subclasses or enumerations directly (they're always wrapped in a list or similar), this never becomes an issue - but it will be an issue for custom resources for implementations that are based on this package, using the utility functions, etc.For the
BaseModel
subclasses one can utilize the__modify_schema__
method (see the pydantic docs here and here).However, for enumerations, one needs to set the
type
value directly when specifying the attribute that has the enumeration type, e.g.:Either one does it like this, or (perhaps more straightforward) we handle
allOf
andanyOf
keys for an OpenAPI schema property, go to the referenced model(s) and retrieve thetype
from there, which should be the same, and present. The main issue here will beanyOf
, which results from aUnion
type annotation, i.e., it could be a set of different types. This is however, not supported by OPTIMADE (essentially), and as such this should probably raise an exception if it's found that there is not a single unique type from all the possible models/types listed in theanyOf
list value.I hope this explanation makes a bit of sense - it's an issue I encountered in the OPTIMADE gateway development, and will lead me to have to develop a specialized
retrieve_queryable_properties()
function, essentially to deal with this.The text was updated successfully, but these errors were encountered: