I am want generate client for yandex api.
Use Docker
When run
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i https://cloud-api.yandex.net/v1/schema/resources/v1/disk/resources -g rust -o /local/out/rust
Exception in thread "main" java.lang.NullPointerException
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:422)
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:144)
at io.swagger.v3.parser.converter.SwaggerConverter.readLocation(SwaggerConverter.java:93)
at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:19)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:516)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:314)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:69)
https://cloud-api.yandex.net/v1/schema/resources/v1/disk/resources
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i https://cloud-api.yandex.net/v1/schema/resources/v1/disk/resources -g rust -o /local/out/rust
this part of the API is normally generated:
https://cloud-api.yandex.net/v1/schema/resources/v1/disk
I got errors when loading the spec with https://editor.swagger.io. Please address those errors and try again.
Your schema is in a very old swagger format:
{
"description": "肖邪泄谢褘 懈 锌邪锌泻懈",
"swaggerVersion": "1.2",
"apis":
If the swagger-parser does not support it, OpenAPI Generator can not do much about it.
Have you a possibility to convert your specification to OpenAPI version 2 or OpenAPI version 3?
It is not me scheme. I want create Rust crate for Yandex Disk API, but not want write boilerplate lot structs manual. You can close this issue.
Maybe older version of Swagger-Parser can convert this old spec version to a newer one like swagger: 2.0.
Perhaps a different statement of the issue is that invalid or outdated swagger specs are not handled elegantly? I don't think that type of problem should manifest as a NPE.
@bmordue agreed. May I know if you've time to file a PR to better handle the NPE?
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:422)
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:144)
at io.swagger.v3.parser.converter.SwaggerConverter.readLocation(SwaggerConverter.java:93)
at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:19)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:516)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:314)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:69)
@wing328 This is a simple fix for the issue described above: https://github.com/OpenAPITools/swagger-parser/pull/6
That was enough for me to build the Rust client without errors, using the command above. I didn't check whether the generated client is correct or complete, or whether this change has unintended effects elsewhere.
How I can try? build from source code?
For the moment there is no reaction from the Swagger-Parser team (see #68).
I have started to integrate and build an alternative version of the Swagger-Parser in this fork OpenAPITools/Swagger-Parser. For the moment this is only for testing purpose, I hope that we will be able to have everything fixed and released in the Swagger-Parser project.
To test it, you need to replace:
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.1</version>
</dependency>
With
<dependency>
<groupId>org.openapitools.swagger.parser</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.2-SNAPSHOT</version>
</dependency>
Precisely remove all this section:
https://github.com/OpenAPITools/openapi-generator/blob/0d952b79db0e7e8330418e9b0b638f9c7de73e31/modules/openapi-generator/pom.xml#L211-L225
And replace it with:
<dependency>
<groupId>org.openapitools.swagger.parser</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.2-SNAPSHOT</version>
</dependency>
If you are testing with the maven or the gradle plugin you can fix the classpath directly in your project.
If you are testing with the CLI, you will need to build it locally.
PS: One last precision: we are not using SNAPSHOT versions in our dependency in our working branches (master, 3.2.x, 4.0.x). This makes the builds not reproducible in the future.
Be sure that there will be a build containing all the fixes (from the official project or from the forked project) so that it can be integrated in the next days/weeks.
Now that https://github.com/swagger-api/swagger-parser/pull/753 was merge you can forget my previous comment and just set 2.0.2-SNAPSHOT for the swagger-parser version:
Like this:
<swagger-parser-version>2.0.2-SNAPSHOT</swagger-parser-version>
(again not something we can commit in our repo, we need to wait until the next release)
The issue in Swagger-Parser was fixed, and with PR #696 OpenAPI-Generator was updated to use a version containing the fix.
This issue reported here, should no longer appear with the newest 3.2.0-SNAPSHOT version.
@bmordue, @andreevlex, can you check it?
@jmini I'm happy to close, thanks
@jmini Thank you. I haven't checked anything yet.
I'll check it tomorrow.
still can't generate Yandex api.
wrote to the developers Yandex.
@andreevlex : my guess is that you now have an other issue (and an other stacktrace). Maybe this issue could be closed and a new one could be created with the issue that appears with the 3.2.1 release.
Most helpful comment
Perhaps a different statement of the issue is that invalid or outdated swagger specs are not handled elegantly? I don't think that type of problem should manifest as a NPE.