Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# From issue-2060: common spec providing an externally referenced header whose
# schema is a $ref to a named type in this same package.
openapi: "3.0.4"
info:
title: Common
version: "0.0.1"
paths: {}
components:
schemas:
ETagSchema:
type: string
description: RFC 7232 entity tag
headers:
ETag:
description: Entity tag header
schema:
$ref: "#/components/schemas/ETagSchema"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# yaml-language-server: $schema=../../../../../configuration-schema.json
package: api
generate:
chi-server: true
strict-server: true
client: true
models: true
import-mapping:
./common/spec.yaml: github.com/oapi-codegen/oapi-codegen/v2/internal/test/references/multipackage/header_ref/gen/common
output: gen/api/api.gen.go
output-options:
skip-prune: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# yaml-language-server: $schema=../../../../../configuration-schema.json
package: common
generate:
models: true
output: gen/common/common.gen.go
output-options:
skip-prune: true
11 changes: 11 additions & 0 deletions internal/test/references/multipackage/header_ref/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Package headerref is a regression test for issue-2060: a response header
// that is an external `$ref` whose schema is itself a `$ref` to a named type
// must qualify that type with the imported package (e.g.
// externalRef0.ETagSchema), both in the strict-server response headers struct
// and in the typed client response wrappers. Before the fix the header field
// referenced an undefined local type and the generated package failed to
// compile.
package headerref

//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.common.yaml common/spec.yaml
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.api.yaml spec.yaml
Loading