Skip to content

fix(stricttpl): move custom header interpolation after set content-type#1133

Merged
1 commit merged intooapi-codegen:masterfrom
henripqt:fix-move-response-custom-header-interpolation
Jul 28, 2023
Merged

fix(stricttpl): move custom header interpolation after set content-type#1133
1 commit merged intooapi-codegen:masterfrom
henripqt:fix-move-response-custom-header-interpolation

Conversation

@henripqt
Copy link
Copy Markdown
Contributor

WHAT

Move the custom response header interpolation in the strict interface template after the Content-Type header is set in order to allow overriding it if needed

WHY

Currently one cannot define a custom Content-Type header if he wished.
For example if one wants to set a Content-Type of application/json; charset-utf8 for backwards compatibility support the only currently available option in openapi v3 would be to add a custom header of Content-Type with a default value like the following :

headers: 
  Content-Type:
    description: The unique ID of the request.
    schema:
      type: string
      default: application/json; charset=utf-8

However in in strict interface implementation custom headers are interpolated prior to the Content-Type being set and therefore setting a custom Content-Type becomes impossible.

HOW

By moving the custom headers interpolation after the call to set the Content-Type we allow greater flexibility.

@henripqt henripqt force-pushed the fix-move-response-custom-header-interpolation branch from b5e2806 to db5e8b9 Compare June 29, 2023 19:41
@ghost ghost merged commit 8210fe4 into oapi-codegen:master Jul 28, 2023
debuggerpk pushed a commit to breuHQ/oapi-codegen that referenced this pull request Sep 18, 2023
…pe (oapi-codegen#1133)

Co-authored-by: Henri Parquet <henri.parquet@banked.com>
danicc097 pushed a commit to danicc097/oapi-codegen that referenced this pull request Aug 31, 2024
…pe (oapi-codegen#1133)

Co-authored-by: Henri Parquet <henri.parquet@banked.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant