Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

chore(oas-to-snippet): replace stringified request body with JSON.stringify and object #1056

Merged
merged 2 commits into from
Nov 19, 2020

Conversation

Dashron
Copy link
Contributor

@Dashron Dashron commented Nov 19, 2020

replace stringified request body with JSON.stringify and object

🧰 What's being changed?

The request body in the node example must be a string. Originally we were translating the JSON object to a string and including that. A JSON.stringified object is difficult to read, so this PR keeps the object literal and wraps it in a JSON.stringify call in the example.

See https://app.asana.com/0/1199087650851461/1198986894847661 for more discussion and example pictures.

🧪 Testing

Go to the petstore example, and the "add a new pet" API call. Start typing in the "category" request body form below the example, and you should see the example automatically update with a request body that is an object literal wrapped in JSON.stringify.

@Dashron Dashron requested a review from erunion November 19, 2020 20:49
@erunion erunion added the type:bug Something isn't working label Nov 19, 2020
@@ -44,6 +44,12 @@ module.exports = (oas, operation, values, auth, lang, oasUrl) => {
};
}

if (lang === 'node') {
language.httpsnippet[2] = {
useObjectBody: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to move this into src/supportedLanguages instead? Since it's not using oasUrl or oas like node-simple snippets are we can probably leave this option contained there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh totally, way better. Didn't notice that config list before. Getting a new pr shortly.

@Dashron Dashron merged commit 2b60206 into next Nov 19, 2020
@Dashron Dashron deleted the fix/nodeExampleRequestBody branch November 19, 2020 23:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants