Haskell-OpenAPI-Code-Generator / Haskell-OpenAPI-Client-Code-Generator

Generate Haskell client code from an OpenAPI 3 specification
46 stars 19 forks source link

Support Common Header #114

Open StevenXL opened 2 weeks ago

StevenXL commented 2 weeks ago

Some APIs require a specific header to be sent with all requests. For example, in Recurly:

// https://recurly.com/developers/api/v2021-02-25/#section/Getting-Started/Versioning

WARNING: Specifying a version is required to get a successful response.

This is not supported by the OpenAPI Specification, as far as I can tell. However, would it be able to add this feature as an option to the generator?

Thinking off the top of my head, we could expand the config data type with a new field of type Request -> Request. createBaseRequest can do what it currently does, plus that new field. The new field could be field in with user-supplied code, maybe via the configuration file.

joel-bach commented 1 week ago

Hey @StevenXL

We had a similar discussion some time ago which led to the conclusion that for the moment, a custom implementation of our MonadHttp is sufficient to achieve what you are asking for, see this comment for a great example given by a member of the community.

I think this should work for you as well, let me know if you disagree, thank you.