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

Nested external references

Open hiddenmarten opened this issue 1 year ago • 1 comments

Hi,

I've encountered an unusual behavior with code generation and wanted to share my findings. While I'm not entirely sure of the root cause, I was able to consistently reproduce the issue.

In summary, when using an external $ref that points to another external $ref within components.parameters (and possibly in components.responses as well), it results in broken aliases.

Here's PR with tests. Here's a link to broken alias.

I suppose it should be:

// IdParam defines model for IdParam.
type IdParam = externalRef1.IdParam

instead of:

// ExternalRef1IdParam defines model for IdParam.
type ExternalRef1IdParam = Id

since, it's an external ref for, IdParam:

  parameters:
    IdParam:
      $ref: "idparam/spec.yaml#/components/parameters/IdParam"

hiddenmarten avatar Oct 19 '24 13:10 hiddenmarten

I've attempted to fix an issue in this PR.

I hope it'll be helpful.

hiddenmarten avatar Oct 20 '24 09:10 hiddenmarten

Hi again @jamietanna, does this fix look good enough to be labeled for the next release?

hiddenmarten avatar Nov 05 '24 19:11 hiddenmarten