Skip to content
Open
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
5 changes: 4 additions & 1 deletion .ai-docs/bilingual-comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ uses libopenapi's strict YAML/JSON parser once, checks the root version marker,
and transfers the parsed AsyncAPI tree to libasyncapi. Mixed formats, ambiguous
markers, unsupported AsyncAPI versions and partial AsyncAPI models fail clearly.

The stack uses libopenapi v0.42.3. Its default YAML alias expansion limit remains
The stack uses libopenapi's default YAML alias expansion limit. It remains
enabled for both formats. Excessive alias expansion fails during loading; normal
aliases retain bounded HTML previews. Doctor tests opt in to trusted excessive
aliases through libasyncapi to exercise graph bounds independently of this limit.
Expand All @@ -27,6 +27,9 @@ defaults afterwards, including comparisons without a custom policy.
## Source and resource ownership

Direct file, URL and revision inputs use the same source loader for both formats.
For an AsyncAPI payload that references an external schema, changes to its
`required` list appear under the payload in `summary`. The JSON report records
the external file and source line for each added or removed entry.
Local revision references use GitRevisionFS. GitHub references use that virtual
filesystem with doctor's GitHub file service, pinned to the same commit SHA.
The working tree is never used to supply a historical sibling reference.
Expand Down
52 changes: 52 additions & 0 deletions cmd/asyncapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,58 @@ func TestAsyncAPIRulesAreScoped(t *testing.T) {
}
}

func TestAsyncAPIExternalRequiredChanges(t *testing.T) {
const spec = `asyncapi: 3.1.0
info: {title: Orders, version: 1.0.0}
components:
messages:
OrderCreated:
payload:
$ref: './schemas.yaml#/Order'
`
writeVersion := func(required string) (string, string) {
t.Helper()
dir := t.TempDir()
root, schema := filepath.Join(dir, "asyncapi.yaml"), filepath.Join(dir, "schemas.yaml")
require.NoError(t, os.WriteFile(root, []byte(spec), 0600))
data := "Order:\n type: object\n required: [" + required + "]\n properties:\n currency: {type: string}\n id: {type: string}\n"
require.NoError(t, os.WriteFile(schema, []byte(data), 0600))
return root, schema
}
left, _ := writeVersion("id")
right, schema := writeVersion("id, currency")
for _, tc := range []struct {
name, from, to, wantRow string
}{
{"added", left, right, "[+] required/currency {X}"},
{"removed", right, left, "[-] required/currency"},
} {
t.Run(tc.name, func(t *testing.T) {
report, err := runLeftRightReport(tc.from, tc.to, summaryOpts{}, nil)
require.NoError(t, err)
require.Len(t, report.Changes, 1)
change := report.Changes[0]
require.Equal(t, "$.components.messages.OrderCreated.payload.required", change.Path)
require.NotNil(t, change.Context)
require.Equal(t, schema, change.Context.DocumentLocation)
if tc.name == "added" {
require.Equal(t, "currency", change.New)
require.True(t, change.Breaking)
require.Equal(t, new(3), change.Context.NewLine)
} else {
require.Equal(t, "currency", change.Original)
require.Equal(t, new(3), change.Context.OriginalLine)
}

commits, err := loadLeftRightCommits(tc.from, tc.to, summaryOpts{})
require.NoError(t, err)
summary, _, _, err := renderSummary(commits, nil, false, true, false, summaryStyles{})
require.NoError(t, err)
require.Contains(t, summary, tc.wantRow)
})
}
}

func TestAsyncAPIInputBoundaries(t *testing.T) {
left, _ := asyncPair(t)
for _, spec := range []string{"openapi: 3.0.0\ninfo: {title: API, version: 1.0.0}\npaths: {}\n", "asyncapi: 2.6.0\ninfo: {title: API, version: 1.0.0}\n", "asyncapi: 3.0.0\nopenapi: 3.0.0\ninfo: {title: API, version: 1.0.0}\n"} {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/pb33f/doctor v0.0.88
github.com/pb33f/go-yaml v0.1.1
github.com/pb33f/libasyncapi v0.0.7
github.com/pb33f/libopenapi v0.42.3
github.com/pb33f/libopenapi v0.42.6-0.20261114224705-db27aae96380
github.com/pb33f/testify v0.1.1
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
github.com/spf13/cobra v1.10.2
Expand Down Expand Up @@ -51,7 +51,7 @@ require (
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/ncruces/go-strftime v1.1.0 // indirect
github.com/pb33f/jsonpath v0.8.4 // indirect
github.com/pb33f/jsonpath v0.8.5 // indirect
github.com/pb33f/jsonschema/v6 v6.0.3 // indirect
github.com/pb33f/ordered-map/v2 v2.3.2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
Expand All @@ -62,7 +62,7 @@ require (
github.com/yuin/goldmark-emoji v1.0.6 // indirect
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc // indirect
golang.org/x/net v0.61.0 // indirect
golang.org/x/sync v0.24.0 // indirect
golang.org/x/sync v0.25.0 // indirect
golang.org/x/sys v0.49.0 // indirect
golang.org/x/text v0.43.0 // indirect
modernc.org/libc v1.77.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ github.com/pb33f/doctor v0.0.88 h1:4hX+P2jxFyF/lfGKw9imOUC2c44exVYDcD5T6r6Zq4I=
github.com/pb33f/doctor v0.0.88/go.mod h1:kFgQgvAm9ESjpaQAzyn82NzQpqpM+zwjZdovS2IeX/Q=
github.com/pb33f/go-yaml v0.1.1 h1:yWGmhVdwzionRnSc/hEJwcfq6PaZL2QdYzyReXBbX7Q=
github.com/pb33f/go-yaml v0.1.1/go.mod h1:QvWdkHP5VjFYAeHMQUkaPQqREaQnBNOXmWzAjNrnSdo=
github.com/pb33f/jsonpath v0.8.4 h1:Yx7fxsKl8scgERL22WhKDs2c6gYNNUonPSWEG8Y194s=
github.com/pb33f/jsonpath v0.8.4/go.mod h1:eO6mgdhw5RgzCxm/bXTi75VUs0/cCYJzdGjMCCUEI6M=
github.com/pb33f/jsonpath v0.8.5 h1:wsbwJbz6MPUTy5fAtiIlOyQb3oblaa5M7qjtdz6orPw=
github.com/pb33f/jsonpath v0.8.5/go.mod h1:eO6mgdhw5RgzCxm/bXTi75VUs0/cCYJzdGjMCCUEI6M=
github.com/pb33f/jsonschema/v6 v6.0.3 h1:TMIkE1xCmnF8Cy+anIBs+r4ASfGtwzfFxYsrrIn0wSU=
github.com/pb33f/jsonschema/v6 v6.0.3/go.mod h1:cYPShw+w1Jrs0YgpE2rk1FLdIAsKfWcotv/54G6ddFo=
github.com/pb33f/libasyncapi v0.0.7 h1:0CTUZwjQm4Fya6Znb7q/1kBWvp/92v5CaB9T55zJMiA=
github.com/pb33f/libasyncapi v0.0.7/go.mod h1:OcM42Lo3J4F9Tz55RZIOxcAubOv1BGRg9gy8Sp36skk=
github.com/pb33f/libopenapi v0.42.3 h1:0VXnFgz04LtWjIsmCqGYA5E2Mx0DOZcOTjy5KHYw88k=
github.com/pb33f/libopenapi v0.42.3/go.mod h1:IlfeXtmcY38KEnGJ4OMWFA8I62BCNamuQa8omLnk6R0=
github.com/pb33f/libopenapi v0.42.6-0.20261114224705-db27aae96380 h1:KZ9Ezi5+sBKrzD3PUIMnCw3vtF1NoW98DmFx2sYJ2lk=
github.com/pb33f/libopenapi v0.42.6-0.20261114224705-db27aae96380/go.mod h1:fzngW6SBMO7ggf7prvQlEB3qY6Rqu5dTGMbUZcy4Ybg=
github.com/pb33f/ordered-map/v2 v2.3.2 h1:wDyaZ2Pv9QLh64X4utCeD5Zoi9nIv2aW3lwv172O5PQ=
github.com/pb33f/ordered-map/v2 v2.3.2/go.mod h1:1OhFrXu3OYw3kM+FXF+Ug3ugmmZ9LE8z0JfQMLvtV0w=
github.com/pb33f/testify v0.1.1 h1:mnHe7uxKt8dyNYEGUspow72VjD264DB5rOJq4bz5tJw=
Expand Down Expand Up @@ -150,8 +150,8 @@ golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw=
golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
Expand Down
Loading