-
Notifications
You must be signed in to change notification settings - Fork 325
feat(ir): extract per-content-type OAS examples into endpoint-level v2Examples #16718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d34c3d2
feat: extract per-content-type examples in OAS importer
adidavid014 c2ea0e7
fix(ir): guard per-content-type example synthesis to multi-content-ty…
adidavid014 ae206b1
fix: update protoc-gen-fern ETE snapshot with contentType field
adidavid014 53a2233
fix: add ir-to-jsonschema snapshots for multi-content-type-examples f…
adidavid014 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/cli/cli/changes/unreleased/per-content-type-examples.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| - summary: | | ||
| Extract per-content-type OpenAPI examples into endpoint-level v2Examples | ||
| tagged with their content type. When an operation declares multiple content | ||
| types (e.g. application/json and application/ld+json) with distinct examples, | ||
| the importer now elevates those examples so docs can display the correct | ||
| example body when the user switches content types. | ||
| type: feat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...ir-to-jsonschema/src/__test__/__snapshots__/multi-content-type-examples/type__Client.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "type": "object", | ||
| "properties": { | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "email": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "name", | ||
| "email" | ||
| ], | ||
| "additionalProperties": false, | ||
| "definitions": {} | ||
| } |
38 changes: 38 additions & 0 deletions
38
...onschema/src/__test__/__snapshots__/multi-content-type-examples/type__ClientResponse.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "type": "object", | ||
| "properties": { | ||
| "client": { | ||
| "oneOf": [ | ||
| { | ||
| "$ref": "#/definitions/ClientWithId" | ||
| }, | ||
| { | ||
| "type": "null" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "additionalProperties": false, | ||
| "definitions": { | ||
| "ClientWithId": { | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string" | ||
| }, | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "email": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "id", | ||
| "name", | ||
| "email" | ||
| ], | ||
| "additionalProperties": false | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
...jsonschema/src/__test__/__snapshots__/multi-content-type-examples/type__ClientWithId.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string" | ||
| }, | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "email": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "id", | ||
| "name", | ||
| "email" | ||
| ], | ||
| "additionalProperties": false, | ||
| "definitions": {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚩 Pre-existing counter bug in OpenRPC example conversion causes unnamed examples to overwrite each other
The
++iincrement atpackages/cli/api-importers/openrpc-to-ir/src/1.x/methods/MethodConverter.ts:360is placed outside theforloop (lines 275–358) but inside theifblock. This meansistays at 0 for every iteration of the loop. When multiple examples lack an explicitname, they all receive the fallback key"Example 1"(line 305:resolvedExample.name ?? \Example ${i + 1}`), and each subsequent unnamed example silently overwrites the previous one in theexamplesrecord. Only the last unnamed example survives. This is a pre-existing bug not introduced by this PR (which only addedcontentType: undefined` at line 330), but it's in the same function and worth noting for a follow-up fix.(Refers to line 360)
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — this is indeed a pre-existing bug (the
++iis outside the loop). This PR only addedcontentType: undefinedat line 330 and doesn't change the iteration logic. I'll note this for a follow-up fix.