-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Description
Steps to reproduce
- Use the following example request in the open api snippet which has this schema that won't generate the request model.
"UploadMultipartRequest": {
"type": "object",
"required": ["file", "request"],
"properties": {
"file": {
"type": "string",
"format": "binary",
"description": "File to upload"
},
"request": {
"$ref": "#/components/schemas/UploadRequest"
}
}
}Generated client (problem)
The generated Retrofit client looks like this:
@MultiPart()
@POST('/v1/upload')
Future<UploadResponse> uploadFile({
@Part(name: 'file') required MultipartFile file,
@Part(name: 'request') required UploadRequest request,
});However:
- The generator does not correctly detect or generate
UploadRequest - This results in:
- unresolved imports
- missing models
- compilation errors
Example generated import:
import '../models/upload_request.dart';BUT THE FILE IS NOT GENERATED.
Expected results
swagger_parser should:
- Detect that the request references an object schema
- Generate the corresponding Dart model (UploadRequest)
- Correctly wire the model into the generated Retrofit client
Alternatively, if nested objects inside multipart/form-data are not supported, the generator should:
- emit a warning
- or treat the field as
Map<String, dynamic>.
Actual results
The generated client references a model that is either:
- not generated
- not resolved correctly
- or imported incorrectly.
Your OpenApi snippet
{
"components": {
"schemas": {
"UploadRequest": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "integer"
},
"anotherField": {
"type": "integer"
}
},
"required": ["name", "id"]
},
"UploadMultipartRequest": {
"type": "object",
"required": ["file", "request"],
"properties": {
"file": {
"type": "string",
"format": "binary",
"description": "File to upload"
},
"request": {
"$ref": "#/components/schemas/UploadRequest"
}
}
}
}
}
}And the endpoint:
{
"/v1/upload": {
"post": {
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/UploadMultipartRequest"
}
}
}
}
}
}
}Code sample
Code sample
[Paste your code here]Logs
Logs
[Paste your logs here]Dart version and used packages versions
Dart version
Flutter 3.38.6Packages version
swagger_parser: ^1.42.0Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels