openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

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

Open dkliban opened this issue 5 years ago • 10 comments

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 avatar Jul 16 '20 11:07 dkliban

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

dkliban avatar Jul 16 '20 11:07 dkliban

@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?

autopp avatar Jul 16 '20 15:07 autopp

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.

dkliban avatar Jul 17 '20 19:07 dkliban

@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 avatar Jul 21 '20 13:07 wing328

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

wing328 avatar Jul 21 '20 13:07 wing328

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

dkliban avatar Jul 21 '20 14:07 dkliban

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

aeneasr avatar Jun 16 '21 06:06 aeneasr

Still an issue :D

aeneasr avatar May 17 '24 11:05 aeneasr

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

wing328 avatar May 17 '24 11:05 wing328

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 :)

aeneasr avatar May 17 '24 13:05 aeneasr