I am creating API documentations for my APIs. while creating am stuck in a problem that : I want to generate server side code for my API by which user can easily implement that code. I read about "codegen" by swagger by which one can generate code in different languages. So any please suggest me how to use that feature to generate code in different language (java,php...). or any alternative for this. also Guide me if i am wrong at any point of view. Thanks in advance.
1 Answer
Given that you've the API documented in OpenAPI/Swagger spec, you can use Swagger Codegen to generate PHP server stub (Slim, Silex, Lumne) very easily.
Please refer to the wiki for more information.
4 Comments
Abhishek Goswami
As i am new to api and its documentation please tell me process of implementing the code in link . not able to understand the code. :(
William Cheng
OK. Instead of running the JAR locally, you can use editor.swagger.io. After you enter/import your spec into editor.swagger.io, you can click on "Generate Server" in the menu at the top and select the server framework (e.g. Slim).
Abhishek Goswami
thanks for this. But i want to show client/server side code on UI documentation of API. But from here only we can download the code. So please tell is there any way to show the client code on swagger UI.
William Cheng
I'm not aware of anyway to do that in Swagger UI. There's a PR to add a API documentation generator in Swagger Codegen which may meet your requirement: github.com/swagger-api/swagger-codegen/pull/3447