Skip to content

Commit 4121b42

Browse files
fredbiclaude
andcommitted
fix(routes): derive body: response description instead of echoing the type name (quirk G1)
A `swagger:route` `Responses:` entry of the form `<code>: body:<Type>` with no trailing description text filled `response.description` with the bare Go type token — `200: body:Pet` → "Pet", `404: body:string` → "string". OAS2 requires a non-empty description, but a type token is not a human description and leaks the Go type name into the published contract. A named `swagger:response` never did this (it takes its description from prose), so the inline body form was the lone inconsistent surface (doc-site quirk G1). buildRouteResponse now derives the fallback description via a new bodyResponseDescription helper, applied identically to the `body:<Type>` form and the definition-fallback `<Model>` form so they agree, in three tiers: 1. the referenced model's own godoc (Title, then Description); 2. the HTTP status reason phrase for a numeric code (200 → "OK"); 3. a neutral "Default response" placeholder for the `default` catch-all and non-standard codes with no godoc. Never leaks the Go token, always non-empty. Witness fixture fixtures/quirks/body-response-description + TestQuirk_BodyResponseDescription cover all three tiers. 14 integration goldens drift — every changed line is a `description` (no schema/$ref/type/code change). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent 041938e commit 4121b42

19 files changed

Lines changed: 252 additions & 46 deletions

‎fixtures/integration/golden/bugs_1109_bodyref_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"operationId": "updateOrder",
1111
"responses": {
1212
"200": {
13-
"description": "order",
13+
"description": "An Order for one or more pets by a user.",
1414
"schema": {
1515
"$ref": "#/definitions/order"
1616
}

‎fixtures/integration/golden/bugs_1109_responseref_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"operationId": "updateOrder",
1111
"responses": {
1212
"200": {
13-
"description": "order",
13+
"description": "An Order for one or more pets by a user.",
1414
"schema": {
1515
"$ref": "#/definitions/order"
1616
}

‎fixtures/integration/golden/bugs_1742_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"responses": {
1919
"200": {
20-
"description": "string",
20+
"description": "OK",
2121
"schema": {
2222
"type": "string"
2323
}

‎fixtures/integration/golden/bugs_1891_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"responses": {
2626
"200": {
27-
"description": "FooOutput",
27+
"description": "FooOutput for output",
2828
"schema": {
2929
"$ref": "#/definitions/FooOutput"
3030
}

‎fixtures/integration/golden/bugs_1934_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"responses": {
1919
"default": {
20-
"description": "someResponse",
20+
"description": "Default response",
2121
"schema": {
2222
"$ref": "#/definitions/someResponse"
2323
}

‎fixtures/integration/golden/bugs_2286_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"operationId": "authLogout",
1111
"responses": {
1212
"200": {
13-
"description": "logoutResponse",
13+
"description": "LogoutResponse is used directly as a response (#2286).",
1414
"schema": {
1515
"$ref": "#/definitions/logoutResponse"
1616
}

‎fixtures/integration/golden/bugs_2922_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
],
2424
"responses": {
2525
"200": {
26-
"description": "GetEnumTestResponse",
26+
"description": "OK",
2727
"schema": {
2828
"$ref": "#/definitions/GetEnumTestResponse"
2929
}

‎fixtures/integration/golden/bugs_2922_skip_enum_desc_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
],
2424
"responses": {
2525
"200": {
26-
"description": "GetEnumTestResponse",
26+
"description": "OK",
2727
"schema": {
2828
"$ref": "#/definitions/GetEnumTestResponse"
2929
}

‎fixtures/integration/golden/bugs_2942_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"operationId": "getVersion",
77
"responses": {
88
"200": {
9-
"description": "string",
9+
"description": "OK",
1010
"schema": {
1111
"type": "string"
1212
}

‎fixtures/integration/golden/bugs_796_schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"responses": {
2626
"200": {
27-
"description": "pingResponse",
27+
"description": "Ping Response",
2828
"schema": {
2929
"$ref": "#/definitions/pingResponse"
3030
}

0 commit comments

Comments
 (0)
⌂ 换网址