Skip to content

Backport field tag customization and media type customization from oapi-codegen-exp #2368

@mromaszewicz

Description

@mromaszewicz

We have a lot of assumptions about how fields should be tagged in generated models, and I'd like to retain current default behavior, but allow the users to override every aspect of this behavior.

In https://github.com/oapi-codegen/oapi-codegen-exp, I've allowed field tags to be fully customized, where users can insert their own field tags by looking at the name in the spec, whether the field is required, etc.
https://github.com/oapi-codegen/oapi-codegen-exp/blob/56dd39ec275d400ae5cdc1eed293719464bbf8c2/codegen/internal/configuration.go#L44[
](https://github.com/oapi-codegen/oapi-codegen-exp/blob/56dd39ec275d400ae5cdc1eed293719464bbf8c2/Configuration.md?plain=1#L293)

Likewise, we have some patterns that we match to identify a content-type as JSON or YAML or whatever, but they can't catch all cases, so I would also like to backport the implementation:

https://github.com/oapi-codegen/oapi-codegen-exp/blob/56dd39ec275d400ae5cdc1eed293719464bbf8c2/codegen/internal/configuration.go#L37
https://github.com/oapi-codegen/oapi-codegen-exp/blob/56dd39ec275d400ae5cdc1eed293719464bbf8c2/Configuration.md?plain=1#L265

https://github.com/oapi-codegen/oapi-codegen-exp/blob/56dd39ec275d400ae5cdc1eed293719464bbf8c2/codegen/internal/configuration.go#L41
https://github.com/oapi-codegen/oapi-codegen-exp/blob/main/Configuration.md?plain=1#L275

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions