@@ -4,23 +4,58 @@ import (
44 "goa.design/goa/v3/eval"
55 goaexpr "goa.design/goa/v3/expr"
66 "goa.design/plugins/v3/docs"
7- "goa.design/plugins/v3/docs/expr"
7+ plugexpr "goa.design/plugins/v3/docs/expr"
88)
99
1010// init registers the docs plugin when importing the DSL.
1111func init () { docs .Register () }
1212
1313// UseJSONTags configures the docs plugin to use JSON struct tags declared via
14- // Meta("struct:tag:json", ...) as field names in generated docs. This setting
15- // affects definitions, payloads, results, and error schemas and examples.
16- func UseJSONTags () { expr .Root .UseJSONTags = true }
14+ // Meta("struct:tag:json", ...) as field names in generated docs.
15+ //
16+ // This setting affects type definitions, payloads, results, and error schemas
17+ // and their examples.
18+ //
19+ // Usage:
20+ //
21+ // var _ = API("my api", func() {
22+ // // Use field names from struct JSON tags throughout docs.json
23+ // docs.UseJSONTags()
24+ // })
25+ func UseJSONTags () { plugexpr .Root .UseJSONTags = true }
1726
1827// InlineRefs configures the docs plugin to inline referenced schemas in JSON
19- // Schema output where possible. Cycles are preserved by keeping $ref.
20- func InlineRefs () { expr .Root .InlineRefs = true }
28+ // Schema output where possible. Cycles are preserved by keeping $ref where
29+ // needed (e.g., recursive references).
30+ //
31+ // Usage:
32+ //
33+ // var _ = API("my api", func() {
34+ // // Prefer inlined schemas rather than $ref when there are no cycles
35+ // docs.InlineRefs()
36+ // })
37+ func InlineRefs () { plugexpr .Root .InlineRefs = true }
38+
39+ // IncludeTypes registers user types to force-emit in docs.json definitions.
40+ // Accepts user types defined via Type or ResultType.
41+ //
42+ // Service and method schemas are always generated by the docs plugin when not
43+ // disabled on the service/method. IncludeTypes does not change service/method
44+ // emission. This is only useful for types that are generated via the "force"
45+ // Goa Meta DSL; it ensures those user types (and their transitive dependencies)
46+ // are included under the top-level "definitions" object.
47+ //
48+ // Usage:
49+ //
50+ // var _ = API("my api", func() {
51+ // // Ensure these shared types appear in docs.json definitions so downstream
52+ // // tooling can resolve schemas by name.
53+ // docs.IncludeTypes(MySharedType, AnotherType)
54+ // })
55+ func IncludeTypes (ts ... goaexpr.UserType ) { plugexpr .Root .IncludeTypes (ts ... ) }
2156
22- // DisableDocs disables docs.json generation for the current service only .
23- // It does not affect OpenAPI generation. Invoke inside a Service DSL.
57+ // DisableDocs disables docs.json generation for the current service or method .
58+ // It does not affect OpenAPI generation. Invoke inside a Service or Method DSL.
2459//
2560// Service("front", func() {
2661// DisableDocs()
0 commit comments