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.75k stars 6.56k forks source link

[REQ] [Java] [Maven] InputSpec download from url #2241

Open Catscratch opened 5 years ago

Catscratch commented 5 years ago

Currently inputSpec must be a file located in the filesystem.

It would be nice to provide an uri like "file:///..." or "http://..." and the maven plugins decides whether it should download the file first or not.

Usually to wanna generate sources for a public service providing a swagger.json file somewhere.

Changes could happen here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java#L383

wing328 commented 5 years ago

I think the input parameter (-i in CLI or inputSpec in plugins) already supports URL. Can you try this one?

https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml

ramzimaalej commented 5 years ago

@wing328 he is referring to the maven-plugin. I will give it a look.

wangtao commented 5 years ago

+1 for https/http supporting

I am using maven plugin for some kind of automatic CI process.

simasch commented 5 years ago

That's a very important feature. APIs are usually published on a web server and you don't want to download it just to generate the code!

wing328 commented 5 years ago

There's a work-in-progress PR: https://github.com/OpenAPITools/openapi-generator/pull/2373

Please help test it when you guys have time.

tobq commented 3 years ago

Has this been implemented?

Gama11 commented 3 years ago

It seems like it has: https://github.com/OpenAPITools/openapi-generator/pull/3826

Arsennikum commented 3 years ago

What about implementation for Gradle plugin?

ghost commented 3 years ago

Looks like it is still not working for redirects: http://petstore.swagger.io/v2/swagger.json

mivchal333 commented 1 year ago

Is it still open? :( It would be so nice feature to use shared api specification between multiple services!

parenko commented 3 months ago

There is an example which works with remote URL: https://github.com/OpenAPITools/openapi-generator/blob/8938f9dea1ef9ba28bf89e0fbb71c33e1c68a665/modules/openapi-generator-maven-plugin/examples/java-client.xml#L51

Maybe you are limited to collapsed ApiSpec.