Skip to content

Commit

Permalink
fix(swagger-ui-plugins): fix fetch code example builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Oct 8, 2024
1 parent 62a3043 commit ac11919
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ describe("requestSnippetGenerator_node_fetch", () => {
const snippet = requestSnippetGenerator_node_fetch(request);
expect(snippet).toMatchInlineSnapshot(`
"try {
const response = await fetch({
const response = await fetch('https://example.com/api/data?query=1', {
method: 'GET',
url: 'https://example.com/api/data?query=1',
headers: {
"Content-Type": "application/json"
},
Expand Down Expand Up @@ -44,9 +43,8 @@ describe("requestSnippetGenerator_node_fetch", () => {
const snippet = requestSnippetGenerator_node_fetch(request);
expect(snippet).toMatchInlineSnapshot(`
"try {
const response = await fetch({
const response = await fetch('https://example.com/api/data', {
method: 'GET',
url: 'https://example.com/api/data',
headers: {
"Content-Type": "text/html"
},
Expand All @@ -72,9 +70,8 @@ describe("requestSnippetGenerator_node_fetch", () => {
const snippet = requestSnippetGenerator_node_fetch(request);
expect(snippet).toMatchInlineSnapshot(`
"try {
const response = await fetch({
const response = await fetch('https://example.com/api/data', {
method: 'GET',
url: 'https://example.com/api/data',
headers: {
"Content-Type": "application/json"
},
Expand Down
6 changes: 2 additions & 4 deletions packages/swagger-ui-plugins/plugins/request-snippets/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ export function requestSnippetGenerator_node_fetch(request: Map<string, unknown>
const headersString = headers ? JSON.stringify(headers, null, 2) : "";

const opts = indent(
[`method: '${method}'`, `url: '${url.href}'`, headersString && `headers: ${headersString}`, bodyString && `body: ${bodyString}`]
.filter(Boolean)
.join(",\n")
[`method: '${method}'`, headersString && `headers: ${headersString}`, bodyString && `body: ${bodyString}`].filter(Boolean).join(",\n")
);

return `try {
const response = await fetch({
const response = await fetch('${url}', {
${opts}
})
const data = await response.json();
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/molecules/Forms/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Meta, StoryObj } from "@storybook/react";
import { useState } from "react";

import { JsonEditorField } from "../JsonEditorField";
import { Select } from "./Select";

export default {
Expand All @@ -25,7 +24,7 @@ export default {
}
} satisfies Meta<typeof Select>;

type Story = StoryObj<typeof JsonEditorField>;
type Story = StoryObj<typeof Select>;

export const Default: Story = {
args: {
Expand Down

0 comments on commit ac11919

Please sign in to comment.