@@ -75,7 +75,10 @@ func TestCheck(t *testing.T) {
7575 }
7676 assertContains (t , err .Error (), "6 schema field issue(s) found" )
7777 assertEqual (t , wantFindings , stdout )
78- assertContains (t , stderr , "checked 17 of 18 methods that take a struct request body (13 body structs, 22 fields)" )
78+ // The field of the struct that the operation returns is left alone: the request body
79+ // schema does not have it, but a response may, so it is not a mistake.
80+ assertNotContains (t , stdout , "CommentRequest.URL" )
81+ assertContains (t , stderr , "checked 18 of 19 methods that take a struct request body (14 body structs, 24 fields)" )
7982 assertContains (t , stderr , "not checked: 1 method whose body is passed by pointer (run paramcheck to convert it)" )
8083 assertContains (t , stderr , "not checked: 1 operation use with no JSON request body" )
8184 assertContains (t , stderr , "11 findings (5 warn, 6 error)" )
@@ -98,7 +101,7 @@ func TestSummary(t *testing.T) {
98101 stats : stats {
99102 files : 209 , methods : 7981 , methodsWithOps : 1301 ,
100103 bodyValue : 206 , bodyPointer : 62 ,
101- structsChecked : 141 , fieldsChecked : 618 , fieldsConditional : 13 ,
104+ structsChecked : 141 , fieldsChecked : 618 , fieldsConditional : 13 , fieldsResponse : 34 ,
102105 usesResolved : 193 , usesNotInPlan : 10 ,
103106 },
104107 byRule : map [string ]int {ruleNotInSchema : 1 , ruleRequiredOmit : 1 , ruleMissingRequiredProp : 1 },
@@ -119,8 +122,9 @@ func TestSummary(t *testing.T) {
119122 // The coverage lines are the same whatever the findings are.
120123 const coverage = `checked 206 of 268 methods that take a struct request body (141 body structs, 618 fields)
121124 not checked: 62 methods whose body is passed by pointer (run paramcheck to convert them)
122- not checked: 10 operation uses that the pinned revision does not document
123- a newer openapi_commit in openapi_operations.yaml would check them
125+ not checked: 10 operation uses that the descriptions this tool loads do not document
126+ each is documented by a plan this tool does not load, such as an older GHES release,
127+ or by none at all; a newer openapi_commit may not help
124128`
125129
126130 var buf bytes.Buffer
@@ -147,6 +151,7 @@ func TestSummary(t *testing.T) {
147151 assertContains (t , got , "scanned 209 files, 7981 methods (1301 with //meta:operation)" )
148152 assertContains (t , got , "resolved operation uses: 193" )
149153 assertContains (t , got , "conditionally required, and left alone: 13 of the 618 fields" )
154+ assertContains (t , got , "in no request body schema, and left alone because a method returns the struct: 34 of the 618 fields" )
150155 assertContains (t , got , "1 not-in-request-schema: the Go field is not in the request body schema" )
151156
152157 // A checkout with nothing to report says so, rather than counting a baseline of nothing.
@@ -187,11 +192,14 @@ func TestCheckGithubFormat(t *testing.T) {
187192func TestCheckVerbose (t * testing.T ) {
188193 t .Parallel ()
189194 _ , stderr , _ := runOnFixture (t , "-verbose" )
190- assertContains (t , stderr , "no //meta:operation annotation: github/issues.go:54 : Untracked (UntrackedRequest)" )
195+ assertContains (t , stderr , "no //meta:operation annotation: github/issues.go:72 : Untracked (UntrackedRequest)" )
191196 // -verbose is the full breakdown of the summary, which the default output leaves out.
192- assertContains (t , stderr , "scanned 4 files, 18 methods (16 with //meta:operation)" )
193- assertContains (t , stderr , "resolved operation uses: 15" )
194- assertContains (t , stderr , "conditionally required, and left alone: 1 of the 22 fields" )
197+ assertContains (t , stderr , "scanned 4 files, 19 methods (17 with //meta:operation)" )
198+ assertContains (t , stderr , "resolved operation uses: 16" )
199+ assertContains (t , stderr , "conditionally required, and left alone: 1 of the 24 fields" )
200+ // The field that no schema has and that the returned struct explains is counted rather
201+ // than reported, so that the exemption is visible.
202+ assertContains (t , stderr , "in no request body schema, and left alone because a method returns the struct: 1 of the 24 fields" )
195203 assertContains (t , stderr , "4 required-but-omittable: the schema REQUIRES the property, but the tag lets it be omitted" )
196204 // The default output leaves the breakdown out, so that it reads as a verdict.
197205 if _ , plain , _ := runOnFixture (t ); strings .Contains (plain , "scanned 4 files" ) {
0 commit comments