Hello,
I've generated a basic microservice with JHipster 6.3.1, then I've tried to generate client connector on an other microservice and I get the following error.
Steps to reproduce
serviceA with jhipsterserviceB with jhipsterserviceB with jhipster opencpi-client with options: user registryThen I get the following error during generation
-attribute info.name is missingentityName.json files generated in the .jhipster directoryHi what are you using to generate the client code? A file or a live endpoint? Can you paste the openapi yml file and the console logs?
Hello,
in order to generate the client code I do:
jhipster openapi-clientfrom a JHipster /swagger-resources live endpointhttp://localhost:8081 from aa freshly generated 6.3.1 project (see .yo file below)default (/v2/api-docs)jhipster openapi-client
INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:openapi-client
INFO! Options: from-cli: true
Welcome to the JHipster OpenApi client Sub-Generator
? Where do you want to import your OpenAPI/Swagger specification from ? From a Jhipster /swagger-resour
ces live doc endpoint
? Enter the URL of the running Jhipster instance http://localhost:8081/
? Select the doc for which you want to create a client default (/v2/api-docs)
? Do you want to use Eureka service discovery ? Yes
? Do you want to save this config for future reuse ? No
Generating java client code for client default (http://localhost:8081/v2/api-docs)
java -Dmodels -Dapis -DsupportingFiles=ApiKeyRequestInterceptor.java,ClientConfiguration.java -jar /Users/vwiencek/fail/sb/node_modules/@openapitools/openapi-generator-cli/bin/openapi-generator.jar generate -g spring -t /Users/vwiencek/fail/sb/node_modules/generator-jhipster/generators/openapi-client/templates/swagger-codegen/libraries/spring-cloud --library spring-cloud -i http://localhost:8081/v2/api-docs --artifact-id default --api-package com.mycompany.myapp.client.default.api --model-package com.mycompany.myapp.client.default.model --type-mappings DateTime=OffsetDateTime,Date=LocalDate --import-mappings OffsetDateTime=java.time.OffsetDateTime,LocalDate=java.time.LocalDate -DdateLibrary=custom,basePackage=com.mycompany.myapp.client,configPackage=com.mycompany.myapp.client.default,title=default
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
| Error count: 1, Warning count: 0
Errors:
-attribute info.name is missing
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:606)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:395)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
events.js:186
throw er; // Unhandled 'error' event
^
Error: Something went wrong while generating default spring client: Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
| Error count: 1, Warning count: 0
Errors:
-attribute info.name is missing
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:606)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:395)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
at Environment.error (/Users/vwiencek/fail/sb/node_modules/yeoman-environment/lib/environment.js:176:40)
at module.exports.error (/Users/vwiencek/fail/sb/node_modules/generator-jhipster/generators/generator-base.js:1464:18)
at /Users/vwiencek/fail/sb/node_modules/generator-jhipster/generators/openapi-client/files.js:91:30
at /Users/vwiencek/fail/sb/node_modules/shelljs/src/exec.js:127:9
at ChildProcess.exithandler (child_process.js:302:5)
at ChildProcess.emit (events.js:209:13)
at maybeClose (internal/child_process.js:1021:16)
at Socket.<anonymous> (internal/child_process.js:430:11)
at Socket.emit (events.js:209:13)
at Pipe.<anonymous> (net.js:658:12)
Emitted 'error' event on Environment instance at:
at Environment.error (/Users/vwiencek/fail/sb/node_modules/yeoman-environment/lib/environment.js:178:15)
at module.exports.error (/Users/vwiencek/fail/sb/node_modules/generator-jhipster/generators/generator-base.js:1464:18)
[... lines matching original stack trace ...]
at Pipe.<anonymous> (net.js:658:12)
Hello,
I've generated a basic microservice with JHipster 6.3.1, then I've tried to generate client connector on an other microservice and I get the following error.
Steps to reproduce
* Create a microservice `serviceA` with jhipster * Create a microservice `serviceB` with jhipster * generate openapi-client from `serviceB` with jhipster `opencpi-client` with options: user registryThen I get the following error during generation
* `-attribute info.name is missing`Overview of the issue
Motivation for or Use Case
Reproduce the error
Related issues
Suggest a Fix
JHipster Version(s)
JHipster configuration
Entity configuration(s)
entityName.jsonfiles generated in the.jhipsterdirectoryBrowsers and Operating System
* [x] Checking this box is mandatory (this is just to show you read everything)
@vwiencek : It would be helpful if you could complete all sections in the bug report; particularly your configuration (.yo-rc.json) files. That way we can reproduce your projects easily. :smile:
yes sorry.
here is my .yo-rc.json
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp"
},
"jhipsterVersion": "6.3.1",
"applicationType": "microservice",
"baseName": "serviceA",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8081",
"authenticationType": "oauth2",
"cacheProvider": "caffeine",
"enableHibernateCache": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "gradle",
"enableSwaggerCodegen": false,
"jwtSecretKey": "NmQwOGFhZjljMGUzZWY1ZTg0OTA2Mjg5YzM2YzMwNzgyYjIzY2QzZGM4MTcyMTdmOTEzOWY5Y2FmMDU0NjYyMDExYmFhYTY5NTc2MzE3NjFkNjJmYjY3OWFjMDZjZGFkZmQ2NGNhNDAwMjMwZDNhYjA5Yzg4NDUxNmNmYjVhYmY=",
"embeddableLaunchScript": false,
"testFrameworks": [],
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"enableTranslation": false,
"clientPackageManager": "npm",
"blueprints": [],
"skipClient": true,
"skipUserManagement": true
}
}
and my second service
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp"
},
"jhipsterVersion": "6.3.1",
"applicationType": "microservice",
"baseName": "serviceB",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8082",
"authenticationType": "oauth2",
"cacheProvider": "caffeine",
"enableHibernateCache": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "gradle",
"enableSwaggerCodegen": false,
"jwtSecretKey": "ZDE0YTJjYmZkN2E4MDkwMzQwOWU3MzNlOGNkZDY3YTJhMzkwZWQ5NDQ4MTBiMGE1MzczNzliNzA0MjUyMWJiZDA1NDg5ZDI4ZmYzZDhlYTBhZWZiNjY0NWJiOGEyZDExYmYzYWRjZjYwM2E5MWIzOTQyOGM3NWZhYTYwOTIxMGY=",
"embeddableLaunchScript": false,
"testFrameworks": [],
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"enableTranslation": false,
"clientPackageManager": "npm",
"blueprints": [],
"skipClient": true,
"skipUserManagement": true
}
}
While working on this issue I realized that the cliName variable defaults to value default returned by swagger and this creates a problem since default is a keyword in Java. Thus I set the default value of cliName to apidocs instead. The above pull request corresponds to that.
@ecostanzi : I did some analysis on this and to me this seems like a deeper issue (similar to https://github.com/OpenAPITools/openapi-generator/issues/1714 maybe) related to the openapi-generator itself. Maybe we need to open a issue there. Let me know what you think. :smile:
@vwiencek : As a workaround, with my above fix and using the --skip-validate-spec flag as suggested by the error, you should be able to get this working. In other words you could just execute the following command to generate the docs;
java -Dmodels -Dapis -DsupportingFiles=ApiKeyRequestInterceptor.java,ClientConfiguration.java -jar /Users/vwiencek/fail/sb/node_modules/@openapitools/openapi-generator-cli/bin/openapi-generator.jar generate -g spring -t /Users/vwiencek/fail/sb/node_modules/generator-jhipster/generators/openapi-client/templates/swagger-codegen/libraries/spring-cloud --library spring-cloud -i http://localhost:8081/v2/api-docs --artifact-id apidocs --api-package com.mycompany.myapp.client.apidocs.api --model-package com.mycompany.myapp.client.apidocs.model --type-mappings DateTime=OffsetDateTime,Date=LocalDate --import-mappings OffsetDateTime=java.time.OffsetDateTime,LocalDate=java.time.LocalDate -DdateLibrary=custom,basePackage=com.mycompany.myapp.client,configPackage=com.mycompany.myapp.client.apidocs,title=apidocs --skip-validate-spec
@vwiencek for now I also suggest to do what @SudharakaP suggests. I opened a new issue to discuss an improvement that could allow you to customize the generation command easily.
@SudharakaP thanks for the insights. I will try to upgrade to a newer version, let's see if something changes.
@vwiencek @ecostanzi @SudharakaP Since #10500 has been merged and there is also #10510 already opened for the improvements, can this ticket be closed?
@DanielFran : #10500 solves a certain bug in the openapi-client generator due to allowing java keywords. We need #10510 to fully fix the original issue I believe; therefore I suggest keeping this open until #10510 is done.
Let's close this ticket in favor of https://github.com/jhipster/generator-jhipster/issues/10510
For me this error happens when the info.license field is {} (empty)
Deleting the license field, or adding a name property inside fixed the issue.