External references are not dereferenced in header->schema
When generating server response models, external package imports are not being set on the referenced header types when their schema specifications are also refs. Similar, but not equal, to issue #1087.
I took a quick look at the code but couldn't very easily figure out where to fix it. Might have time to look over it in more detail at a later time and see if I can produce a fix myself.
Reproducing steps
Building on the import-mapping/multipackages examples.
Full example committed here: https://github.com/radhus/oapi-codegen/commit/695a09a9c2907cb064344dc4fc2cd7be35c16d02
Add a header and schema in common/api.yml:
components:
schemas:
[...]
ETagSchema:
type: string
description: RFC 7232
headers:
ETag:
description: Custom header
schema:
$ref: "#/components/schemas/ETagSchema"
Use header in admin/api.yml:
paths:
/admin/user/{id}:
get:
[...]
responses:
200:
[...]
headers:
ETag:
$ref: '../common/api.yaml#/components/headers/ETag'
Struct with wrong type
Regenerate with strict-server: true to get the response structs generated. Look at admin/server.gen.go
type GetUserById200ResponseHeaders struct {
ETag ETagSchema
}
Expected result
The schema should be referenced from the other package:
type GetUserById200ResponseHeaders struct {
ETag externalRef0.ETagSchema
}
Maybe related #2088 ?