Skip to content

Render field descriptions on $ref fields in swagger - #469

Merged
shhegde-px merged 1 commit into
masterfrom
swagger-ref-descriptions
Nov 30, 2026
Merged

shhegde-px merged 1 commit into
masterfrom
swagger-ref-descriptions

Conversation

@aks-px

@aks-px aks-px commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:
protoc-gen-swagger writes field docs next to $ref:

"type": {
  "$ref": "#/definitions/CloudCredentialInfoType",
  "description": "Cloud provider type. Not editable via Update: ..."
}

In Swagger 2.0 an object with $ref is replaced entirely by the thing it
points to, so description/title next to it are ignored. Scalar fields and
message-level descriptions have no $ref, so they were unaffected.

protoc-gen-swagger v1.16.0 (which we pin to stay on grpc-gateway v1) has no
option to change this. The fix in protoc-gen-openapiv2 (use_allof_for_refs)
needs a toolchain migration.

Fix

Post-process the generated swagger in make proto with jq, wrapping any $ref
that has sibling keys in a single-item allOf:

"type": {
  "description": "Cloud provider type. Not editable via Update: ...",
  "allOf": [{ "$ref": "#/definitions/CloudCredentialInfoType" }]
}

Which issue(s) this PR fixes (optional)
Closes #

Special notes for your reviewer:

@aks-px
aks-px force-pushed the swagger-ref-descriptions branch from 3f1be5d to bda1ef2 Compare November 2, 2026 10:42
@aks-px aks-px changed the title PB-18216: Render field descriptions on $ref fields in swagger Render field descriptions on $ref fields in swagger Nov 2, 2026
@aks-px
aks-px force-pushed the swagger-ref-descriptions branch from bda1ef2 to ed0caaf Compare November 10, 2026 04:53
@shhegde-px
shhegde-px merged commit 1413589 into master Nov 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants