jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.48k stars 4.02k forks source link

Models classes generated by openapi-generator have unknown imports #11010

Closed avdev4j closed 4 years ago

avdev4j commented 4 years ago
Overview of the issue

Hi team, when we use the openapi-generator (wrapped by our openapi-client subgenerator) the generated classes import the following class import org.openapitools.jackson.nullable.JsonNullable;.

The problem is that we don't have the org.openapitools.jackson dependency in our pom.

After some research it's appeard that this bug is known by the openapi community, but no fix has been done yet. https://github.com/OpenAPITools/openapi-generator/issues/2901

Motivation for or Use Case
Reproduce the error

run the subgenerator openapi-client with an openapi spec api.yml

Related issues
Suggest a Fix

I suggest to add the dependency when using our openapi-client. It's not really smart, but at least the generated code can be compiled and run. We can also add a comment in the code to link the openapi-generator issues and remember why we did the hack.

I know this a hack and I don't have a fully satisfying solution.

Otherwise the solutions suggested by the community are :

JHipster Version(s)
consume-api-workshop@0.0.1-SNAPSHOT /Users/aviard/projects/perso/consumeApiWorkshop
└── (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "io.github.openapiworkshop",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.5.1",
    "applicationType": "monolith",
    "baseName": "consumeApiWorkshop",
    "packageName": "io.github.openapiworkshop",
    "packageFolder": "io/github/openapiworkshop",
    "serverPort": "8081",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en"
    ],
    "blueprints": [],
    "openApiClients": {
      "openApiWorkshop": {
        "spec": "../openApiWorkshop/src/main/resources/swagger/api.yml",
        "generatorName": "spring"
      }
    }
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "1.8.0_202" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_202-b08) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.202-b08, mixed mode)

git version 2.19.0

node: v10.13.0

npm: 6.5.0

yeoman: 2.0.5

yarn: 1.13.0

Docker version 19.03.4, build 9013bf5

docker-compose version 1.24.1, build 4667896b

Entity configuration(s) entityName.json files generated in the .jhipster directory

N/A

Browsers and Operating System
pascalgrimaud commented 4 years ago

@avdev4j : plz, don't forget to update the area + theme label, to have better visibility, rather than letting the default undefined labels

PierreBesson commented 4 years ago

@avdev4j I agree with you that the dependency need to be added dynamically to the existing app. Maybe we can use the existing jhipster hooks that are used by blueprints to add a dependency.