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

[Objc] Request specific headers #4127

Open oursodon opened 8 years ago

oursodon commented 8 years ago
Description

I need to add an authorization header to each request. This header is generated for every request.

I would normally do so by subclassing AFHTTPRequestSerializer, this is not an option since the request serializer is being recreated before request : see.

Is there another way to do it ?

Swagger-codegen version

Version : 2.3.0

Suggest a Fix

I'm working on a fix, I'll submit a PR later.

wing328 commented 8 years ago

@quentin-coursodon in your spec, have you defined a proper security setting for the endpoints?

cc @mateuszmackowiak

oursodon commented 8 years ago

@wing328 We are using a custom Auth method, not "basic", "apiKey" or "oauth2".

oursodon commented 8 years ago

Actually, I use the WSSE Authentication protocol. What do you think about adding WSSE support ?

I could implement it in java and objc .

wing328 commented 7 years ago

@quentin-coursodon I think that's a good idea. I'm sure REST API owners whose APIs leverage WSSE Authentication protocol will welcome the change.

Please implement that as an option, which is disabled by default.

If you need help on anything, just let us know. The community is here to help.

oursodon commented 7 years ago

Hi @wing328 !

Adding full support for WSSE Authentication would mean making changes to swagger-core, swagger-parser, and swagger-codegen. Furthermore, I guess we should add it to openAPI specification. I'm not sure I'll have enough time to do all of this...

However, I could provide a way to edit headers before each request so that any header based authentication mechanism could be implemented externally.

wing328 commented 7 years ago

@quentin-coursodon agreed that it would require some work to make swagger codegen support WSSE authentication.

I would suggest you to start a discussion in Swagger Spec github repo to see if there's any plan to support WSSE in the spec level: https://github.com/OAI/OpenAPI-Specification/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20wsse