OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.72k stars 6.55k forks source link

[REQ] Ability to skip package names in the Java Model classes #3963

Open premkumar-masilamani opened 5 years ago

premkumar-masilamani commented 5 years ago

Is your feature request related to a problem? Please describe.

I am trying to create the Java Model classes for the below argo workflow open api spec.

https://raw.githubusercontent.com/argoproj/argo/master/api/openapi-spec/swagger.json

Here is the command that I used to create the java model classes.

    java -Dmodels -DmodelTests=false -DmodelDocs=false -jar openapi-generator-cli.jar generate \
        --input-spec $ARGO_WORKFLOW_OPENAPI_SPEC_FILE \
        --generator-name java \
        --model-package $ARGO_MODEL_JAVA_PACKAGE_NAME \
        --config openapi-config.json \
        --output ../../../../

Here is the config.json

{
  "serializableModel": true,
  "serializationLibrary": "gson",
  "dateLibrary": "java8"
}

What I get is a bunch of java model classes with the package name prefixed to the classname.

image

Describe the solution you'd like

What I expect is just the class name, without the package names prefix.

image

Describe alternatives you've considered

I tried swagger-codegen and the Open API Generator Plugin in IntelliJ. The output is the same.

Additional context

I see an option to skip the package names for Kotlin. Not for Java.

wing328 commented 5 years ago

I would suggest updating the spec instead to replace "io.argoproj.workflow.v1alpha1" with an empty string.

The challenge I see is that we need to add the same option to all generators, which do not seem like a good idea.

premkumar-masilamani commented 5 years ago

Hi @wing328 - This spec is autogenerated from an opensource project called argo-workflows. I can check with the team. But the point is - if the option to skip the package name is available for Kotlin, why not for Java and other languages?