feat: add sdk snippet generation integration#9717
Draft
shelby-moore wants to merge 3 commits intoKong:developfrom
Draft
feat: add sdk snippet generation integration#9717shelby-moore wants to merge 3 commits intoKong:developfrom
shelby-moore wants to merge 3 commits intoKong:developfrom
Conversation
7328cb8 to
1ed4eb3
Compare
ryan-willis
reviewed
Mar 17, 2026
packages/insomnia/src/ui/components/modals/generate-code-modal.tsx
Outdated
Show resolved
Hide resolved
| ...har.queryString.map(({ name, value }) => ({ in: 'query' as const, name, value })), | ||
| ...har.headers.map(({ name, value }) => ({ in: 'header' as const, name, value })), | ||
| ]; | ||
| const body = har.postData?.text ? tryParseJson(har.postData.text) : undefined; |
Contributor
There was a problem hiding this comment.
Since this will be empty for other body formats we support, should we only show the Stainless options if there is no body or a set request body's mimeType can be parsed as JSON? (Maybe this is more a question for Stainless) can we translate from other formats to make the generate call?
Generating an SDK snippet without the body when the request itself has it doesn't feel right to me
packages/insomnia/src/ui/components/modals/generate-code-modal.tsx
Outdated
Show resolved
Hide resolved
packages/insomnia/src/ui/components/modals/generate-code-modal.tsx
Outdated
Show resolved
Hide resolved
| objc: 'clike', | ||
| ocaml: 'mllike', | ||
| typescript: 'javascript', | ||
| kotlin: 'clike', |
packages/insomnia/src/ui/components/modals/generate-code-modal.tsx
Outdated
Show resolved
Hide resolved
packages/insomnia/src/ui/components/modals/generate-code-modal.tsx
Outdated
Show resolved
Hide resolved
packages/insomnia/src/ui/components/modals/__tests__/generate-code-modal.test.ts
Show resolved
Hide resolved
ryan-willis
reviewed
Mar 17, 2026
| }, | ||
| }); | ||
|
|
||
| expect(result.body).toEqual({ username: 'alice', age: '30' }); |
|
|
||
| if (har.postData) { | ||
| if (har.postData.params) { | ||
| body = Object.fromEntries(har.postData.params.map(({ name, value }) => [name, value ?? ''])); |
Contributor
There was a problem hiding this comment.
TODO: how we'd support this[that][more] if the body structure in the spec is nested (and if this applies/works with the snippet api)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR introduces a secondary "mode" to the existing
Generate Client Codefeature for requests. When available, Stainless will be used to generate the client code snippet. When unavailable, the codepath falls back to the existing http snippet client code generation.