Skip to content

[BUG] Java Client Generator Produces Models with Missing Properties #20889

@jwise-sncr

Description

@jwise-sncr

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

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions