swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

trying to use the Bash code generator, but bash isn't in the list of supported languages?

Open scottrobey opened this issue 4 years ago • 4 comments

Description

This may be a dumb question, or maybe I'm just doing it wrong, but I'm unable to get the Swagger code generator to work out-of-the-box to generate Bash client code. I am able to get it working to generate Ruby and Java client code, but not bash.

Is there something special I need to do to get bash code generation working and I just missed it in the README?

Swagger-codegen version

I'm using: https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.30/swagger-codegen-cli-3.0.30.jar

Swagger declaration file content or url

I can provide the swagger JSON if necessary but that doesn't seem to be the issue here because the JSON works fine for other languages.

Command line used for generation
> java -jar swagger-codegen-cli-3.jar generate -l bash -i ~/Downloads/myapi.json -o ./myapi-client

Exception in thread "main" java.lang.RuntimeException: Can't load config class with name bash Available: dart
aspnetcore
csharp
csharp-dotnet2
go
go-server
dynamic-html
html
html2
java
jaxrs-cxf-client
jaxrs-cxf
inflector
jaxrs-cxf-cdi
jaxrs-spec
jaxrs-jersey
jaxrs-di
jaxrs-resteasy-eap
jaxrs-resteasy
micronaut
spring
nodejs-server
openapi
openapi-yaml
kotlin-client
kotlin-server
php
python
python-flask
r
ruby
scala
scala-akka-http-server
swift3
swift4
swift5
typescript-angular
typescript-axios
typescript-fetch
javascript

        at io.swagger.codegen.v3.CodegenConfigLoader.forName(CodegenConfigLoader.java:31)
        at io.swagger.codegen.v3.cli.SwaggerCodegen.main(SwaggerCodegen.java:96)
Caused by: java.lang.ClassNotFoundException: Bash
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at io.swagger.codegen.v3.CodegenConfigLoader.forName(CodegenConfigLoader.java:29)
        ... 1 more
Steps to reproduce

java -jar swagger-codegen-cli-3.jar generate -l bash -i ~/Downloads/myapi.json -o ./myapi-client

Related issues/PRs

May be related? https://github.com/swagger-api/swagger-codegen/issues/11052

Suggest a fix/enhancement

scottrobey avatar Dec 09 '21 03:12 scottrobey

I was able to workaround this by using the online generator and embedding the Swagger JSON in the curl request to the online generator: curl -X POST -H "content-type:application/json" --data "@<path to JSON file containing spec>" https://generator.swagger.io/api/gen/clients/bash

scottrobey avatar Dec 09 '21 21:12 scottrobey

Bump. What's the reason this isn't shown in the official list?

NorseGaud avatar Mar 20 '23 19:03 NorseGaud

Also, quick update for v3 json:

❯ curl -i -X POST -H "content-type:application/json" --data "{ \"spec\": $(cat veertuinc-anka-build-cloud-controller-1.33.0-swagger.json) }" https://generator.swagger.io/api/gen/clients/bash

NorseGaud avatar Mar 20 '23 19:03 NorseGaud

The ⬆️ no longer works 😢

koszta5 avatar Oct 24 '23 11:10 koszta5