swagger-api / swagger-api/swagger-codegen

[JAVA] Model import in JSON.java file using Swagger Codegen

Open
#7,836 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Generating java client from editor.swagger.io

Using command mvn clean package to get swagger-java-client-1.0.0 library, but command prompt is showing this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) onproject swagger-java-client: Compilation failure
[ERROR] /C:/java-client/src/main/java/io
/swagger/client/JSON.java:[30,1] package io.swagger.client.model does not exist

Yesterday it was working fine.

Swagger generated code is importing a package in JSON.java class:

import io.swagger.client.model.*;

But somehow this package is not available in the autogenerated java-client.

I have tried removing this import and compiled the project again it compiled and build successfully, but while using the library file (swagger-java-client-1.0.0) API stopped working.

Then i tried with my earlier version of yaml file to generate code which was working fine yesterday but somehow it is showing the same error.

This model package was not generated in my project which I generated yesterday neither the import (import io.swagger.client.model.*;) was there in my JSON.java file.

expected result:
Should generate JAVA client code which is compilable with or without the model import.

Thank You
Neeraj

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

Start by reproducing the generated Java client from editor.swagger.io and running mvn clean package. Inspect the generated JSON.java import of io.swagger.client.model.* and whether the io.swagger.client.model package is generated; done means the generated client compiles and its API remains usable without manually removing the import.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.