http strict request bodies should be optional by default
request bodies should be optional by default see https://spec.openapis.org/oas/v3.1.0#fixed-fields-10 or https://swagger.io/docs/specification/describing-request-body/
but as we can see here https://github.com/deepmap/oapi-codegen/blob/621b44626ac9a1aa6c9fdda97324a58569227281/pkg/codegen/templates/strict/strict-http.tmpl#L50, we check that a content type is set only when multiple request bodies are defined, so if our one and only request body is not declared as required, this generated code will return an error , i made this custom template to handle that issue https://gist.github.com/emilien-puget/6d0e0af27c72f4cf331991cccfeb96f4#file-strict-http-tmpl-L50
i also made a custom template https://gist.github.com/emilien-puget/6d0e0af27c72f4cf331991cccfeb96f4#file-strict-interface-tmpl-L15 to handle required body https://github.com/deepmap/oapi-codegen/blob/621b44626ac9a1aa6c9fdda97324a58569227281/pkg/codegen/templates/strict/strict-interface.tmpl#L15 as seen here, when the body is set as required we could drop the pointer on the body.
would you be interested having a PR that change the behavior of the generated code to handle such cases ? we could have an operation-output option like "optional-request-bodies" to switch to this new behavior.
Interesting, thank you! Yes we'd appreciate a PR for that, and agreed that having it behind optional-request-bodies would be best :raised_hands:
started to do stuff and things regarding this issue there
@jamietanna have you had the chance to take a look at my draft?