oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

`x-go-type-import` ignored unless property of object

Open deefdragon opened this issue 3 years ago • 0 comments

I use google's UUID quite a bit in my code. The adition of x-go-type-import made that trivial to use in API generation, unfortunatly, sometimes the generation imports the gofrs/uuid package instead, and I believe I have narrowed down why.

Of the following three cases, only the Schema property one imported the google variant.

Schema direct type

#...
compoents:
  schemas:
    UUID:
      type: string
      x-go-type: uuid.UUID
      x-go-type-import:
        name: uuid
        path: github.com/google/uuid

Schema property

#...
compoents:
  schemas:
    foo:
      type: object
      properties:
        bat:
          type: string
          x-go-type: uuid.UUID
          x-go-type-import:
            name: uuid
            path: github.com/google/uuid

Path Paremeter

#...
      parameters:
        - name: webhook
          in: path
          description: The ID of the webhook that is being called.
          required: true
          schema:
            type: string
            x-go-type: uuid.UUID
            x-go-type-import:
              name: uuid
              path: github.com/google/uuid

deefdragon avatar Sep 23 '22 09:09 deefdragon