OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.79k stars 6.57k forks source link

[BUG] Ruby client doesn't compile when Cookie Header Auth is present in OpenAPI schema #6959

Open dkliban opened 4 years ago

dkliban commented 4 years ago
Description

When cookie support for header auth is present in the OpenAPI schema v3, the Ruby client produced contains nothing after the : on the following line:

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache#L173

On the other hand the Python client is generated correctly.

My understanding is that cookie header auth is not supported by the Ruby client, but the client should still compile.

openapi-generator version

4.3.1

Suggest a fix

In our current workflow we replace line 173 from the template with https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/python/configuration.mustache#L488

However, that is probably not exactly right because it gives the wrong impression to the user that cookie auth is supported, when in reality it is not.

dkliban commented 4 years ago

@wing328 @cliffano @zlx @autopp: Should I make a PR for the proposed solution or do you have a better solution in mind?

autopp commented 4 years ago

@dkliban Thanks for report.

However, that is probably not exactly right because it gives the wrong impression to the user that cookie auth is supported, when in reality it is not.

I agree with you. Offcourse, the best solution is supporting cookie auth. But for the time being, I think it's okay to generate an error in RubyClientCodegen if cookie-auth was included.

@OpenAPITools/generator-core-team Is there a precedent where the Codegen class will generate an error depending on the contents of the spec?

dkliban commented 4 years ago

My suggested fix doesn't work. It produces a client that runs, but then it fails at run time. We ended up removing cookie auth from the OpenAPI schema before generating the Ruby client.

wing328 commented 4 years ago

@OpenAPITools/generator-core-team Is there a precedent where the Codegen class will generate an error depending on the contents of the spec?

We seldom do that. Sometimes we throw warnings to inform the users that certain things in the spec are not yet supported.

wing328 commented 4 years ago

@dkliban Your suggested fix looks like a good start. Mind sharing more about the run time failure?

dkliban commented 4 years ago

@wing328 The traceback can be seen here: https://github.com/pulp/pulpcore/pull/785#discussion_r455976578

aeneasr commented 3 years ago

For anyone looking, this is an issue in the 5.1.x branch as well.

aeneasr commented 5 months ago

Still an issue :D

wing328 commented 5 months ago

@aeneasr may I know if you've time to contribute a fix or would like to sponsor the work?

aeneasr commented 5 months ago

Hey, sorry for the last +1 comment here. Absolutely, we'll try to get it sorted. I think the OP also included a potential patch. Unfortunately I never wrote Ruby before but I'll manage :)