Skip to content
Closed
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
3 changes: 3 additions & 0 deletions internal/test/issues/issue-695/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package externalref

//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=externalref.cfg.yaml spec.yaml
10 changes: 10 additions & 0 deletions internal/test/issues/issue-695/externalref.cfg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package: externalref
generate:
models: true
embedded-spec: true
import-mapping:
./packageA/spec.yaml: github.com/deepmap/oapi-codegen/v2/internal/test/issues/issue-695/packageA
./packageB/spec.yaml: github.com/deepmap/oapi-codegen/v2/internal/test/issues/issue-695/packageB
output: externalref.gen.go
output-options:
skip-prune: true
119 changes: 119 additions & 0 deletions internal/test/issues/issue-695/externalref.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions internal/test/issues/issue-695/imports_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package externalref

import (
"testing"

"github.com/stretchr/testify/require"

packageA "github.com/deepmap/oapi-codegen/v2/internal/test/issues/issue-695/packageA"
packageB "github.com/deepmap/oapi-codegen/v2/internal/test/issues/issue-695/packageB"
)

func TestParameters(t *testing.T) {
b := &packageB.ObjectB{}
_ = Container{
ObjectA: &packageA.ObjectA{ObjectB: b},
ObjectB: b,
}
}

func TestGetSwagger(t *testing.T) {
_, err := packageB.GetSwagger()
require.Nil(t, err)

_, err = packageA.GetSwagger()
require.Nil(t, err)

_, err = GetSwagger()
require.Nil(t, err)
}

func TestExternalRefIsResolvedCorrectly(t *testing.T) {
resp := packageA.TestApiResponse{}

expected := packageB.ResponseC{}

resp.JSON400 = &expected
}
10 changes: 10 additions & 0 deletions internal/test/issues/issue-695/packageA/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package: packageA
generate:
models: true
embedded-spec: true
client: true
output-options:
skip-prune: true
import-mapping:
../packageB/spec.yaml: github.com/deepmap/oapi-codegen/v2/internal/test/issues/issue-695/packageB
output: externalref.gen.go
3 changes: 3 additions & 0 deletions internal/test/issues/issue-695/packageA/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package packageA

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