OpenAPITools / OpenAPITools/openapi-generator
[BUG] [dart-dio] _id is generated as id
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating a model a property _id is transformed and becomes id in the resulting dart class. In the provided example this breaks the class as it already has another id property.
I tested this on latest master with this command (hosting the yml on a public gist):
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
-i https://gist.githubusercontent.com/flodaniel/65ffdf1e803773606dc42dccd58ba021/raw/7ce9e4e7721e1df9bb28c7d2de94581351f387ad/gistfile1.txt -g dart-dio -o /local/out/bad_id_generation
openapi-generator version
openapi-generator-cli 6.2.1
commit : b0ce532
built : 2022-11-01T09:40:00Z
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
OpenAPI declaration file content or url
https://gist.github.com/flodaniel/65ffdf1e803773606dc42dccd58ba021
openapi: 3.0.0
info:
title: Bad _id generation
version: 0.0.1
paths: {}
tags: []
servers: []
components:
schemas:
ConflictingIdProperty:
type: object
properties:
id:
type: string
_id:
type: string
Generation Details
openapi-generator generate -i ./bad_id_generation.yml -g dart-dio -o ./bad_id_generation
Steps to reproduce
- Run the generation
- review the resulting
conflicting_id_property.dartfile with the conflicting id properties.
Related issues/PRs
Suggest a fix
The issue is probably within class.mustache (https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class.mustache). baseName is correct but name is missing the _.
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 with modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class.mustache, then reproduce the issue using the provided OpenAPI gist and dart-dio generation command. Review the generated conflicting_id_property.dart file; done means the _id and id properties remain distinct in the generated Dart class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100