Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator fails with NPE #48

Open
aSapien opened this issue Jul 15, 2019 · 3 comments
Open

Generator fails with NPE #48

aSapien opened this issue Jul 15, 2019 · 3 comments

Comments

@aSapien
Copy link

aSapien commented Jul 15, 2019

Steps to reproduce:

Run
swagger-codegen generate -i https://raw.githubusercontent.com/opsgenie/opsgenie-oas/master/swagger.json -l scala -o ./ogswagger/

Result:

Outputs the content of swagger.json to stdout and appends the following at the end:

Exception in thread "Thread-1" java.lang.NullPointerException
	at io.swagger.v3.parser.converter.SwaggerConverter.lambda$convert$0(SwaggerConverter.java:199)
	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
	at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:198)
	at io.swagger.v3.parser.converter.SwaggerConverter.readLocation(SwaggerConverter.java:95)
	at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16)
	at io.swagger.codegen.v3.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:495)
	at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:340)
	at java.lang.Thread.run(Thread.java:748)

I've tried using the same config as in the pom.xml with the following command, but got the same result:

swagger-codegen generate -c ./config.json --invoker-package com.opsgenie.oas.sdk --api-package com.opsgenie.oas.sdk.api --model-package com.opsgenie.oas.sdk.model -i ./swagger.json -l scala --output ./

config.json:

{
    "groupId": "com.opsgenie.oas",
    "artifactId": "opsgenie-sdk-swagger",
    "artifactVersion": "1.0.9",
    "developerName": "Alp, Baris, Mustafa, Halil, Alperen, Zafer",
    "developerEmail": "[email protected]",
    "developerOrganization": "OpsGenie",
    "developerOrganizationUrl": "https://www.opsgenie.com/",
    "hideGenerationTimestamp": "true",
    "dateLibrary": "joda",
    "library": "jersey2",
    "sortParamsByRequiredFlag": "false",
    "useBeanValidation": "true",
    "performBeanValidation": "true",
    "supportJava6": "false",
    "useRuntimeException": "true",
    "licenseName": "Apache License 2.0 (Apache-2.0)",
    "licenseUrl": "https://www.apache.org/licenses/LICENSE-2.0"
 }

Please assist 🙏

@wing328
Copy link

wing328 commented Jul 24, 2019

@aSapien Seems like the spec contains validation errors:

$ swagger-cli validate https://raw.githubusercontent.com/opsgenie/opsgenie-oas/master/swagger.json
Swagger schema validation failed.
  Additional properties not allowed: nullable at #/definitions/EscalationRepeat/properties/closeAlertAfterAll

JSON_OBJECT_VALIDATION_FAILED

After the spec has been updated to address the validation issue, you may also want to try OpenAPI Generator to generate the clients, e.g.

npm install @openapitools/openapi-generator-cli -g
openapi-generator generate -i https://raw.githubusercontent.com/opsgenie/opsgenie-oas/master/swagger.json -g scala-httpclient-deprecated -o /tmp/scala

@bougar
Copy link

bougar commented Feb 6, 2020

Try with swagger-codegen v2.4.14. The cause of the most part of the problems is that the swagger specification is not correctly adapted to swagger: 2.0. It is mixed with the openapi:3.0.x specification :(

@bougar
Copy link

bougar commented Feb 28, 2020

It should be fixed on #53 :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants