OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java] `additionalProperties: true` generates different outputs between OAS 2.0 and 3.0
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
I have an object declared as:
Application:
type: object
required:
- id
- created
properties:
id:
type: integer
description: Unique ID for this entity.
created:
type: string
format: date-time
description: The moment this entity was created.
modified:
type: string
format: date-time
description: The moment this entity was last modified.
attributes:
type: object
description: Arbitrary properties associated with this entity
additionalProperties: true
In OAS3, the generated docs and object output for this object looks like:
**attributes** | **Map<String, Object>** | Arbitrary properties associated with this entity | [optional]
In OAS2, the generated output is:
**attributes** | **Object** | Arbitrary properties associated with this entity | [optional]
Why do I get a different output depending on the OAS version? I'd like to keep the OAS2 output after I've migrated to OAS3, is there a config option that I missed to prevent this?
openapi-generator version
Lastest (docker)
Generation Details
cmd:
docker run \
--rm \
-v "$$(pwd)/../../generated/java":/out \
-v "$$(pwd)/../../codegen-shared/all.yaml":/tmp/src/all.yaml \
-v "$$(pwd)/templates":/tmp/src/templates \
-v "$$(pwd)/config.json":/tmp/src/config.json \
-w /tmp/src \
openapitools/openapi-generator-cli:latest generate \
-g java \
-i all.yaml \
-c config.json \
-t templates \
-o /out \
--artifact-version=$(artifactVersion)
config:
{
"modelPackage": "...",
"apiPackage": "...",
"artifactId": "...",
"artifactUrl": "https://github.com/...",
"library": "okhttp-gson",
"hideGenerationTimestamp": true,
"gitUserId": "...",
"gitRepoId": "..."
}
Steps to reproduce
- Use a basic OAS3/OAS2 skeleton with an object that contains
additionalProperties - Run the generator.
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 the supplied OAS2/OAS3 skeleton and the Java generator invocation, comparing the generated model and documentation output for additionalProperties: true. Inspect the referenced templates and config.json, then add or run a regression case covering both specification versions; done means the output follows the agreed behavior consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100