Open marcustut opened 10 months ago
@marcustut That is by desing. Excerpt from the docs:
value_type = ... Can be used to override default type derived from type of the field used in OpenAPI spec. This is useful in cases where the default type does not correspond to the actual type e.g. when any third-party types are used which are not ToSchemas nor primitive types. The value can be any Rust type what normally could be used to serialize to JSON or either virtual type
Object
orValue
, or an alias defined using#[aliases(..)]
.Object
will be rendered as generic OpenAPI object(type: object)
.Value
will be rendered as any OpenAPI value (i.e. no type restriction).
Though perhaps in future this can be made configurable. But as of now there are no such plans.
I have a struct
Object
and in my Axum routes I use it like so
The generated OpenAPI Specs then becomes
but the correct output should be
"$ref": "#/components/schemas/Object"
instead of"type": "object"
Note
If I rename the struct from
Object
toStorageObject
then it behaves normally again where it outputs"$ref": "#/components/schemas/StorageObject"
.