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

[BUG] Golang - When using import mappings, import mapping is not properly generated when using composition plus slice pointer type

Open chaslain opened this issue 7 months ago • 2 comments

one.yaml

schemas:
  Thing:
          type: object
          properties:
           Property: value
  Example:
    properties:
      Thing
        type: array
        items: $ref "#/components/schemas/Thing"
          

two.yaml

schemas:
   MyThing:
     allOf:
       - $ref: "one.yaml#/components/schemas/Example'
       - type: object
          properties: # whatever one might add here...

Output when generating two.yaml:

type MyThing struct {
    Thing *[]Thing
}

Expected output generating two.yaml:

type MyThing struct {
    Thing *[]externalRef0.Thing
}
Steps to reproduce
  1. create two specs, one referencing the other
  2. Reference a slice type from 1 to another
  3. optional reference a non slice type to see desired behavior
  4. write configuration file to point import mapping of spec 2 to spec 1's output generation
  5. Run the generator
Suggest a fix

Use same external mapping logic when type is a slice pointer.

chaslain avatar Jun 20 '25 18:06 chaslain

This issue does not appear in master - is it time for another release?

Cannot access master without forking.

chaslain avatar Jun 23 '25 16:06 chaslain

Are you sure this doesn't happen in master? I tried it with the master build, but it isn't working for me.

LarsStegman avatar Sep 15 '25 11:09 LarsStegman