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.97k stars 6.04k forks source link

[JAVA][Retrofit2] How to use auto-generated client code? #7266

Open Defozo opened 6 years ago

Defozo commented 6 years ago
Description

Swagger generates instructions how to use auto-generated client code: Eg. https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/java/retrofit2/docs/PetApi.md However, Configuration and ApiException used in the example code don't exist in the generated sources. So, how to use it?

Swagger-codegen version

2.3.0

Command line used for generation

I'm using gradle plugin.

Steps to reproduce

Generate java code using Retrofit2 library from PetStore API example.

wing328 commented 6 years ago

@Defozo the auto-generated is copied from the Java (okhttp-gson) generator.

May I know if you've time to fix the auto-generated doc? If yes, I can show you some good starting points.

Defozo commented 6 years ago

Well, even if I had a time, I think I wouldn't be the right person for repairing that. I'm a beginner user of Swagger & Retrofit2.

wing328 commented 6 years ago

@Defozo that's ok. I would suggest you try the default (okhttp-gson) Java API client instead, which comes with better documentation on how to use it.

8secz-johndpope commented 5 years ago

https://github.com/675767159/CarManager_Android/blob/057ed6274d2f4b347fd25a30a257c33519178227/app/src/main/java/com/qcwp/carmanager/engine/ApiException.java

I think it's actually supposed to extend IOException