Skip to content

x-oapi-codegen-extra-tags #1508

@tandem97

Description

@tandem97

Hello! Here is a simple exmaple of spec:

openapi: 3.0.3
components:
  schemas:
    queue:
      type: object
      properties:
        ticket:
          x-oapi-codegen-extra-tags:
            db: ticket,merge
          allOf: 
            - $ref: "#/components/schemas/ticket"

    queue2:
      type: object
      properties:
        ticket:
          x-oapi-codegen-extra-tags:
            db: ticket,merge
          $ref: "#/components/schemas/ticket"
          
    ticket:
      type: object
      properties:
        clientName:
          type: string
      required:
        - clientName

Here is generated code:

type Queue struct {
	Ticket *Ticket `db:"ticket,merge" json:"ticket,omitempty"`
}

// Queue2 defines model for queue2.
type Queue2 struct {
	Ticket *Ticket `json:"ticket,omitempty"`
}

// Ticket defines model for ticket.
type Ticket struct {
	ClientName string `json:"clientName"`
}

I found a lifehack to add tags to Ticket field with help of allOf, but i expected it works without allOff. Code was generated with v.2.1.0 generator. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions