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
17.04k stars 6.03k forks source link

Are type-mappings and import-mappings supported for python code generator? #8023

Open tamalsaha opened 6 years ago

tamalsaha commented 6 years ago

It seems that type-mappings and import-mappings are not supported for python code generator. How can I skip code generation for some models in swagger.json and point them to an external import path in my generated python client ?

ghost commented 6 years ago

There's a missing "definitions" support on behalf of the OpenCore API package. It is being fixed, but not yet available.... Without "definitions" in your schema API you wont be seeing any model structures with proper names, only the "models" used by the API functions (and anonymously named InlineResponse20000...)

tamalsaha commented 6 years ago

@rubimazaki, is there an issue or pr I can follow? Is there any timeline on when this will be available?

joris255 commented 6 years ago

@rubimazaki Thank you for your reply. Is there a workaround that comes in mind? @tamalsaha What did you end up doing?

tamalsaha commented 6 years ago

I have not done anything. I am still waiting for this project to do something or give us an update on it.

ghost commented 6 years ago

From what I understand: swagger should be written from swagger definitions -> server generated code -> then client generated code will work (other way being: employing swagger classes in your server -> generate swagger defs out of these). The swagger definitions generated this way are hard to make consistent. Generated client code is buggy, and documentation is (very) hard to maintain. Finally, our dev team solution was ... to write a python script to process the API typescript + the swagger schema JSON, and rename the model files + fixing the names of the TypeScript client. In my understanding if the schema would be written first, with the definitions of the structures written FOR the functions (and not the other way round), things would have been easier to us (both server/client teams). In addition: for the server team to supply well formatted docs, some special mustached parameters had to be injected into the definition of the function parameters, a thing that rendered the auto generated TypeScript API functions un-compile-able.

tamalsaha commented 6 years ago

From what I understand: swagger should be written from swagger definitions -> server generated code -> then client generated code will work (other way being: employing swagger classes in your server -> generate swagger defs out of these).

Yes. Like Google protocol buffer and grpc. I will we could all just settle on that as the standard. Swagger has been just a awful experience with generators that can't do basic stuff.

CermakM commented 5 years ago

Is there any solution to this?

michaelkarrer81 commented 4 years ago

+1 same problem importMappings seems to have no effect for python