Skip to content

Commit

Permalink
rework code samples resolving and state
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-white committed May 20, 2024
1 parent db710ca commit ec84034
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ export const xcodeSamples: IHttpOperation = {
iid: 'PUT_codeSamples',
method: 'put',
path: '/todos/{todoId}',
summary: 'Update Todo with code sample overrides',
summary: 'Update Todo with code samples',
extensions: {
'x-codeSamples': [
{
lang: 'shell',
lib: 'wget',
label: 'wGet',
source:
'wget \'https://api.stoplight.io/todos/1\' --header=\'Content-Type: application/json\' --header=\'X-Stoplight-Resolver: true\' --header=\'b-account-id: account-id-default\' --header=\'account-id: account-id-default\' --header=\'message-id: example value\' --header=\'message-id: another example\' --header=\'message-id: something else\' --data-raw \'{"name":"string","completed":true,"id":0,"completed_at":"2021-06-30T14:59:00Z","created_at":"2021-06-30T14:59:00Z","updated_at":"2021-06-30T14:59:00Z","user":{"name":"string","age":0,"type":"STANDARD"}}\'',
},
{
lang: 'Shell',
lang: 'shell',
lib: 'curl',
source:
'curl \'https://api.stoplight.io/todos/1\' --header=\'Content-Type: application/json\' --header=\'X-Stoplight-Resolver: true\' --header=\'b-account-id: account-id-default\' --header=\'account-id: account-id-default\' --header=\'message-id: example value\' --header=\'message-id: another example\' --header=\'message-id: something else\' --data-raw \'{"name":"string","completed":true,"id":0,"completed_at":"2021-06-30T14:59:00Z","created_at":"2021-06-30T14:59:00Z","updated_at":"2021-06-30T14:59:00Z","user":{"name":"string","age":0,"type":"STANDARD"}}\'',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default meta;

export const Story = createHoistedStory({ data: httpOperation, layoutOptions: { compact: 600 } });

export const StoryWithCodeSampleOverrides = createHoistedStory({
export const StoryWithCustomCodeSamples = createHoistedStory({
data: xcodeSamples,
layoutOptions: { compact: 600 },
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,32 @@ HoistedStory.args = {
};
HoistedStory.storyName = 'RequestSamples';

export const RequestSampleWithOverrides = Template.bind({});
export const RequestSampleWithCustomCodes = Template.bind({});

RequestSampleWithOverrides.args = {
codeSampleOverrides: [
RequestSampleWithCustomCodes.args = {
customCodeSamples: [
{
lang: 'shell',
label: 'cURL',
lib: 'curl',
source: 'echo "Hello, World from cURL!"',
},
{
lang: 'shell',
label: 'Wget',
lib: 'wget',
source: 'echo "Hello, World from Wget!"',
},
{
lang: 'go',
label: 'Go',
source: 'Some go sample',
},
{
lang: 'rust',
label: 'Rust',
source: 'Hello rustations!',
},
],
request: {
url: 'https://google.com',
Expand All @@ -52,4 +64,4 @@ RequestSampleWithOverrides.args = {
queryString: [],
},
};
RequestSampleWithOverrides.storyName = 'RequestSampleWithOverrides';
RequestSampleWithCustomCodes.storyName = 'RequestSampleWithCustomCodes';

0 comments on commit ec84034

Please sign in to comment.