Skip to content

Commit 3daf53c

Browse files
committed
refactor(docs): update generated code and golden files
1 parent 80a9a88 commit 3daf53c

3 files changed

Lines changed: 31 additions & 29 deletions

File tree

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,33 @@
1313

1414
*.swp
1515
.vscode/*
16+
17+
*.out
18+
*.test
19+
gengoalint
20+
21+
# OS generated files
22+
.DS_Store
23+
.DS_Store?
24+
._*
25+
.Spotlight-V100
26+
.Trashes
27+
ehthumbs.db
28+
Thumbs.db
29+
30+
# Binaries for programs and plugins
31+
*.so
32+
*.so.*
33+
*.a
34+
*.dll
35+
*.exe
36+
*.exe~
37+
*.test
38+
*.out
39+
*.log
40+
41+
# vendored dependencies
42+
vendor/
43+
44+
# protoc
45+
protoc-*/

docs/examples/calc/gen/docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"api":{"name":"calc","title":"Calculator Service","version":"0.0.1","servers":{"calc":{"name":"calc","description":"Default server for calc","services":["calc"],"hosts":{"localhost":{"name":"localhost","server":"calc","uris":["http://localhost:80","grpc://localhost:8080"]}}}}},"services":{"calc":{"name":"calc","description":"The calc service performs additions on numbers","methods":{"add":{"name":"add","payload":{"type":{"$ref":"#/definitions/AddPayload","required":["left","right"]},"example":{"left":8605439947149783646,"right":6825552331577586910}},"result":{"type":{"type":"integer","format":"int64"},"example":5855163322465186600}}}}},"definitions":{"AddPayload":{"title":"AddPayload","type":"object","properties":{"left":{"type":"integer","description":"Left operand","example":4288748512599820841,"format":"int64"},"right":{"type":"integer","description":"Right operand","example":4212629202012168060,"format":"int64"}},"example":{"left":1698882017578366363,"right":6747375795581831989},"required":["left","right"]}}}
1+
{"api":{"name":"calc","title":"Calculator Service","version":"0.0.1","servers":{"calc":{"name":"calc","description":"Default server for calc","services":["calc"],"hosts":{"localhost":{"name":"localhost","server":"calc","uris":["http://localhost:80","grpc://localhost:8080"]}}}}},"services":{"calc":{"name":"calc","description":"The calc service performs additions on numbers","methods":{"add":{"name":"add","payload":{"type":{"$ref":"#/definitions/AddPayload","required":["left","right"]},"example":{"left":8605439947149783646,"right":6825552331577586910}},"result":{"type":{"type":"integer","format":"int64"},"example":5855163322465186600}}}}},"definitions":{}}

docs/generate_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -329,34 +329,6 @@ func TestInlineRefs_MethodRootPayloadResult(t *testing.T) {
329329
}
330330
}
331331

332-
func TestInlineRefs_CrossPackage(t *testing.T) {
333-
t.Cleanup(func() { plugexpr.Root.UseJSONTags = false; plugexpr.Root.InlineRefs = false })
334-
docsMap := genDocs(t, func() {
335-
InlineRefs()
336-
API("Test", func() {})
337-
// Service "S1" uses a type from a different package.
338-
Service("S1", func() {
339-
Method("M1", func() {
340-
Payload(testdata.CrossPackageType)
341-
HTTP(func() { GET("/") })
342-
GRPC(func() {})
343-
})
344-
})
345-
})
346-
347-
svc := docsMap["services"].(map[string]any)["S1"].(map[string]any)
348-
methods := svc["methods"].(map[string]any)
349-
m1 := methods["M1"].(map[string]any)
350-
pt := m1["payload"].(map[string]any)["type"].(map[string]any)
351-
if _, hasRef := pt["$ref"]; hasRef {
352-
t.Fatalf("expected inlined payload schema for cross-package type, found $ref: %#v", pt)
353-
}
354-
assert.Equal(t, "object", pt["type"])
355-
props := pt["properties"].(map[string]any)
356-
_, hasA := props["A"]
357-
assert.True(t, hasA)
358-
}
359-
360332
func TestInlineRefs_CrossService(t *testing.T) {
361333
t.Cleanup(func() { plugexpr.Root.UseJSONTags = false; plugexpr.Root.InlineRefs = false })
362334
docsMap := genDocs(t, func() {

0 commit comments

Comments
 (0)