OpenAPITools / OpenAPITools/openapi-generator

[BUG] [JAVA] serializationLibrary option not working and AbstractOpenApiSchema missing when generating only models

Open
#18,829 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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?
    Expected output:
  1. OpenAPI Generator should generate a code that can successfully be compiled. i.e. it should generate all classes and interfaces required to successfully build the project, even if generator is generating only model classes.
  2. OpenAPI Generator should respect the config options mentioned on the website i.e. it should use Jackson as serialiser library if the option is provided.

Actual output:

  1. The code generated has AbstractOpenApiSchema class missing when generating only models. Code can be found here
  2. The code uses Gson as serialization library inspire of providing serializationLibrary=jackson as configOptions. Code can be found here
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am trying to generate only models using openapi-codegen. I am using Java generator using Gradle plugin and generated source has following issues:

  1. The code generated has AbstractOpenApiSchema class missing when generating only models. Code can be found here
  2. The code uses Gson as serialization library inspire of providing serializationLibrary=jackson as configOptions. Code can be found here
openapi-generator version

Gradle plugin -> id("org.openapi.generator") version "7.6.0"
CLI Version -> openapi-generator-cli 7.6.0

OpenAPI declaration file content or url

https://github.com/usrivastava92/openapi-codegen/blob/8e1e2a889600d3ccdab8153900ad39d0f66f6195/openapi.json

Steps to reproduce
  1. Clone https://github.com/usrivastava92/openapi-codegen
  2. Run cd java && gradle openApiGenerate command inside the repo to replicated the issue
Screenshot 2024-06-02 at 7 57 14 PM Screenshot 2024-06-02 at 7 57 19 PM Screenshot 2024-06-02 at 7 57 29 PM
Related issues/PRs

N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the models-only generation from the referenced openapi.json using the Gradle openApiGenerate entry point in java/build.gradle.kts. Inspect the generated AssistantObjectToolsInner.java and build.gradle.kts output, then trace the Java generator's model-only and serializationLibrary handling. Done means the generated models compile with AbstractOpenApiSchema available and serializationLibrary=jackson produces Jackson rather than Gson.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.