Skip to content

[Feature][Go][Ability to specify different field name than JSON derived one #15002

@wtrocki

Description

@wtrocki

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Golang has an internal linting rule that forces users to use strict naming schemes for some of the properties.
For example, ID property is preferred over Id.

Generated golang client doesn't meet those as it is based on the exact property names.

Examples:
https://github.com/golang/lint/blob/master/lint.go#LL770-L809
https://github.com/mgechev/revive/blob/b03e54f617491984b41f0411b69326f94d03a76f/lint/utils.go#L89-L128

openapi-generator version

master

OpenAPI declaration file content or url
    properties:
       id:
          type: string
          description: id

Generates Id struct property where in go typically this would be ID.

Generation Details
Steps to reproduce

Generate client that has id field.

Related issues/PRs
Suggest a fix

Enable: x-codegen-name extension to rename field in openapi without affecting json value.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions