Description
Example
#[derive(ToSchema)]
pub struct ResponsePayload<T: ToSchema> {
data: Vec<T>,
}
#[derive(ToSchema)]
pub struct PrimaryData {
id: String,
value: u32,
}
Expected definition
{
"components": {
"schemas": {
"PrimaryData": {
"properties": {
"id": {
"type": "string"
},
"value": {
"format": "int32",
"minimum": 0,
"type": "integer"
}
},
"required": [
"id",
"value"
],
"type": "object"
},
"ResponsePayload_PrimaryData": {
"properties": {
"data": {
"items": {
"$ref": "#/components/schemas/PrimaryData"
},
"type": "array"
}
},
"required": [
"data"
],
"type": "object"
}
}
},
"info": {
"description": "",
"license": {
"name": ""
},
"title": "utoipa-generic-response",
"version": "0.1.0"
},
"openapi": "3.1.0",
"paths": {}
}
Actual definition
{
"components": {
"schemas": {
"PrimaryData": {
"properties": {
"id": {
"type": "string"
},
"value": {
"format": "int32",
"minimum": 0,
"type": "integer"
}
},
"required": [
"id",
"value"
],
"type": "object"
},
"ResponsePayload_PrimaryData": {
"properties": {
"data": {
"items": {
"properties": {
"id": {
"type": "string"
},
"value": {
"format": "int32",
"minimum": 0,
"type": "integer"
}
},
"required": [
"id",
"value"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"data"
],
"type": "object"
}
}
},
"info": {
"description": "",
"license": {
"name": ""
},
"title": "utoipa-generic-response",
"version": "0.1.0"
},
"openapi": "3.1.0",
"paths": {}
}
25,39c25
< "properties": {
< "id": {
< "type": "string"
< },
< "value": {
< "format": "int32",
< "minimum": 0,
< "type": "integer"
< }
< },
< "required": [
< "id",
< "value"
< ],
< "type": "object"
---
> "$ref": "#/components/schemas/PrimaryData"
@juhaku is this expected? Is there a workaround? Where should I start looking if I wanted to be able to fix this or provide an alternative?
What's surprising is that traits associated types (ex: T::SomeType
) are not inlined. Yet they very much depend on T
.
Metadata
Metadata
Assignees
Labels
No labels