swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.74k stars 6.02k forks source link

Generate server stubs for PHP-SLIM not working for 3.x #11816

Open RickKukiela opened 2 years ago

RickKukiela commented 2 years ago
Description

I tried to generate my server stubs with the PHP SLIM framework code and I get the following:

$ java -jar swagger-codegen-cli.jar generate -i https://petstore.swagger.io/v2/swagger.json -l slim -o /c/Projects/test
Exception in thread "main" java.lang.RuntimeException: Can't load config class with name slim 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: slim
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:375)
        at io.swagger.codegen.v3.CodegenConfigLoader.forName(CodegenConfigLoader.java:29)
        ... 1 more

As you can see, there is no slim option in the list. The documentation says it should work. If I run the same command against my 2x jar the command succeeds. The problem is that 2x does not support Open API 3.0.3 and I need to support 3.0.3.

Swagger-codegen version

3.0.34

Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
RickKukiela commented 2 years ago

I obtained my jar file via the following command: Invoke-WebRequest -OutFile swagger-codegen-cli.jar https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.34/swagger-codegen-cli-3.0.34.jar