swagger-api / swagger-api/swagger-codegen-generators
Dart Generator: JSON Array of Files
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
Hiya! Thanks for the great packages for code gen. I have a bug with the Dart generator.
Since this is a commercial project, I cannot share the entire openAPI spec, but I will attempt to share the relevant parts. We have an Order object that looks like this:
Order:
type: object
properties:
id:
type: string
state:
$ref: "#/components/schemas/OrderState"
accepted:
type: string
format: date
files:
type: array
items:
$ref: "#/components/schemas/File"
File:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
It defines an Order object that can contain a list of File. We define our own File, but when I generate the Code, our definition isn't used, and the Files array is instead transformed into an array of MultipartFile.
Two problems:
- The code that is generated does not compile. It attempts to call a
MultipartFile.listFromJsonconstructor from inside theOrder.fromJsonmethod, which does not exist on theMultipartFileclass. - This isn't what we expected to happen, but is this intentional? This is my first time generating code from a Swagger spec, but this doesn't seem intuitive. If we wanted a multipart file, I assumed we'd change the spec to look like this: https://swagger.io/docs/specification/describing-request-body/file-upload/
Happy to help address this issue, but would appreciate a bit more info from your side on whether this is "working as intended" but needs a fix for the constructor, or if it shouldn't be coerced into a different type at all.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Dart generator by locating how schema array items are mapped and how MultipartFile is selected, then compare that behavior with the Order.fromJson output described here. Done means the generated code compiles and the File schema is handled consistently with the intended OpenAPI definition, including a clear decision about multipart coercion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100