oapi-codegen
oapi-codegen copied to clipboard
External references' references are not imported via import-mapping configuration
When an external reference imported via import-mapping such as the following has references (a chain of references), they are not resolved/imported and the generated code does not compile.
api/oapi.cfg.yml
# ...
import-mapping:
../item/openapi.yml: github.com/deepmap/oapi-codegen/internal/test/issues/issue-1223/item
output: api.gen.go
# ...
api/openapi.yml
# ...
paths:
/item/{itemid}:
$ref: '../item/openapi.yml#/components/pathItems/ItemPath'
# ...
item/openapi.yml
# ...
pathItems:
ItemPath:
get:
summary: Get an item
operationId: getItem
parameters:
- $ref: '#/components/parameters/ItemID'
responses:
'200':
description: success
content:
application/json:
schema:
$ref: '#/components/schemas/Item'
# ...
git clone https://github.com/wafer-bw/oapi-codegen
cd oapi-codegen/internal/test
go generate ./issues/issue-1223/...
go test ./issues/issue-1223/...
# # github.com/deepmap/oapi-codegen/internal/test/issues/issue-1223/api
# issues/issue-1223/api/api.gen.go:21:35: undefined: ItemID
# issues/issue-1223/api/api.gen.go:33:13: undefined: ItemID
# issues/issue-1223/api/api.gen.go:78:9: undefined: ItemID
# issues/issue-1223/api/api.gen.go:85:29: undefined: Item
# issues/issue-1223/api/api.gen.go:114:59: undefined: ItemID
# FAIL github.com/deepmap/oapi-codegen/internal/test/issues/issue-1223 [build failed]
# ? github.com/deepmap/oapi-codegen/internal/test/issues/issue-1223/item [no test files]
# FAIL
- Diff/PR: https://github.com/wafer-bw/oapi-codegen/pull/1
- Commit: https://github.com/deepmap/oapi-codegen/commit/943aa4f27cf35a8aadda637fe23a4b71d2a09262
- Issue Folder