OpenAPITools / OpenAPITools/openapi-generator
[BUG] Java Client Generator Produces Models with Missing Properties
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'm using the Gradle plugin to generate a Java client for the Snyk REST API at https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2Fgit-blob-12edd9f86fd8fcbc43720f531b172cba3ff73669%2Frest-spec.json?alt=media.
Here's the relevant build.gradle snippet:
openApiGenerate {
inputSpec = layout.projectDirectory.file('src/main/openapi/openapi.json').asFile.absolutePath
generatorName = 'java'
outputDir = layout.buildDirectory.file('generated-sources/java').get().asFile.absolutePath
packageName = 'com.synchronoss.snyk.rest'
apiPackage = 'com.synchronoss.snyk.rest.api'
modelPackage = 'com.synchronoss.snyk.rest.model'
configOptions = [
library: 'okhttp-gson',
disallowAdditionalPropertiesIfNotPresent: 'false',
]
}
The generated OrgAttributes model class contains properties group_id, is_personal, name, and slug. However, the generated model class is missing properties access_requests_enabled, created_at, and updated_at.
When I call the OrgsApi.listOrgs method, it fails because the response contains created_at and updated_at properties which the model class does not understand.
The Snyk REST API specification validates. I don't see anything wrong with how the OrgAttributes schema is written in the document.
openapi-generator version
7.12.0
OpenAPI declaration file content or url
Generation Details
Here's the relevant build.gradle snippet:
openApiGenerate {
inputSpec = layout.projectDirectory.file('src/main/openapi/openapi.json').asFile.absolutePath
generatorName = 'java'
outputDir = layout.buildDirectory.file('generated-sources/java').get().asFile.absolutePath
packageName = 'com.synchronoss.snyk.rest'
apiPackage = 'com.synchronoss.snyk.rest.api'
modelPackage = 'com.synchronoss.snyk.rest.model'
configOptions = [
library: 'okhttp-gson',
disallowAdditionalPropertiesIfNotPresent: 'false',
]
}
Steps to reproduce
Use the Gradle plugin to execute the openApiGenerate task. Compare the OrgAttributes component schema in the OpenAPI specification to the generated OrgAttributes model class. The generated model class does not contain all of the properties listed in the component schema.
Related issues/PRs
Suggest a fix
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 Gradle openApiGenerate task, the OrgAttributes component schema, and the generated OrgAttributes model using openapi-generator 7.12.0 with the okhttp-gson library. Compare the schema with the generated model and reproduce the OrgsApi.listOrgs response. Done means access_requests_enabled, created_at, and updated_at are generated and handled correctly.
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