Skip to content

Remove placeholder typings and add @types dependencies #8

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import kebabCase from "lodash/kebabCase";
import unionBy from "lodash/unionBy";
import uniq from "lodash/uniq";
import Converter from "openapi-to-postmanv2";
import Collection from "postman-collection";
import sdk from "postman-collection";
import { Collection } from "postman-collection";
import * as sdk from "postman-collection";

import { sampleRequestFromSchema } from "./createRequestExample";
import { OpenApiObject, TagGroupObject, TagObject } from "./types";
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-openapi-docs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* ========================================================================== */

import { SidebarItemDoc } from "@docusaurus/plugin-content-docs/src/sidebars/types";
import type Request from "postman-collection";
import Request from "postman-collection";

import {
InfoObject,
Expand Down
2 changes: 2 additions & 0 deletions packages/docusaurus-theme-openapi-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"@types/file-saver": "^2.0.5",
"@types/lodash": "^4.14.176",
"@types/pako": "^2.0.3",
"@types/postman-collection": "^3.5.11",
"@types/react-modal": "^3.16.3",
"concurrently": "^5.2.0",
"docusaurus-plugin-openapi-docs": "^4.4.0",
"docusaurus-plugin-sass": "^0.2.3",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import React, { useState, useEffect, type JSX } from "react";
import React, { useState, useEffect } from "react";

import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
Expand All @@ -14,7 +14,7 @@ import CodeTabs from "@theme/ApiExplorer/CodeTabs";
import { useTypedSelector } from "@theme/ApiItem/hooks";
import cloneDeep from "lodash/cloneDeep";
import codegen from "postman-code-generators";
import sdk from "postman-collection";
import * as sdk from "postman-collection";

import { CodeSample, Language } from "./code-snippets-types";
import {
Expand All @@ -31,7 +31,7 @@ export interface Props {
codeSamples: CodeSample[];
}

function CodeTab({ children, hidden, className }: any): JSX.Element {
function CodeTab({ children, hidden, className }: any): React.JSX.Element {
return (
<div role="tabpanel" className={className} {...{ hidden }}>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Server from "@theme/ApiExplorer/Server";
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
import sdk from "postman-collection";
import * as sdk from "postman-collection";
import { FormProvider, useForm } from "react-hook-form";

import makeRequest from "./makeRequest";
Expand Down Expand Up @@ -126,7 +126,7 @@ function Request({ item }: { item: ApiItem }) {
} else {
await handleResponse(res);
}
} catch (e: any) {
} catch (e) {
console.log(e);
dispatch(setResponse("Connection failed"));
dispatch(clearCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* ========================================================================== */

import { Body } from "@theme/ApiExplorer/Body/slice";
import sdk from "postman-collection";
import * as sdk from "postman-collection";

function fetchWithtimeout(
url: string,
Expand Down Expand Up @@ -156,8 +156,9 @@ async function makeRequest(
myHeaders.delete("Content-Type");

myBody = new FormData();
if (Array.isArray(request.body.formdata.members)) {
for (const data of request.body.formdata.members) {
const members = (request.body as any)?.formdata?.members;
if (Array.isArray(members)) {
for (const data of members) {
if (data.key && data.value.content) {
myBody.append(data.key, data.value.content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ServerObject,
} from "docusaurus-plugin-openapi-docs/src/openapi/types";
import cloneDeep from "lodash/cloneDeep";
import sdk from "postman-collection";
import * as sdk from "postman-collection";

type Param = {
value?: string | string[];
Expand Down Expand Up @@ -73,15 +73,15 @@ function setQueryParams(postman: sdk.Request, queryParams: Param[]) {
([key, val]) =>
new sdk.QueryParam({
key: `${param.name}[${key}]`,
value: val,
value: String(val),
})
);
} else if (param.explode) {
return Object.entries(jsonResult).map(
([key, val]) =>
new sdk.QueryParam({
key: key,
value: val,
value: String(val),
})
);
} else {
Expand Down Expand Up @@ -181,7 +181,10 @@ function setPathParams(postman: sdk.Request, pathParams: Param[]) {
});
});

postman.url.variables.assimilate(source, false);
postman.url.variables.assimilate(
source.filter((v): v is sdk.Variable => v !== undefined),
false
);
}

function buildCookie(cookieParams: Param[]) {
Expand All @@ -207,7 +210,9 @@ function buildCookie(cookieParams: Param[]) {
([key, val]) =>
new sdk.Cookie({
key: key,
value: val,
value: String(val),
domain: "",
path: "",
})
);
} else {
Expand All @@ -217,14 +222,18 @@ function buildCookie(cookieParams: Param[]) {
value: Object.entries(jsonResult)
.map(([key, val]) => `${key},${val}`)
.join(","),
domain: "",
path: "",
});
}
}
} else {
// Handle scalar values
return new sdk.Cookie({
key: param.name,
value: param.value,
value: String(param.value),
domain: "",
path: "",
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Request from "@theme/ApiExplorer/Request";
import Response from "@theme/ApiExplorer/Response";
import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
import sdk from "postman-collection";
import * as sdk from "postman-collection";

function ApiExplorer({
item,
Expand All @@ -21,7 +21,9 @@ function ApiExplorer({
item: NonNullable<ApiItem>;
infoPath: string;
}) {
const postman = new sdk.Request(item.postman);
const postman = new sdk.Request(
item.postman ? (item.postman as any).toJSON() : {}
);

return (
<>
Expand Down

This file was deleted.

This file was deleted.

14 changes: 14 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4294,6 +4294,13 @@
resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-6.0.3.tgz#705bb349e789efa06f43f128cef51240753424cb"
integrity sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==

"@types/postman-collection@^3.5.11":
version "3.5.11"
resolved "https://registry.yarnpkg.com/@types/postman-collection/-/postman-collection-3.5.11.tgz#384ca38d5635d5ec1d999d70c84c3c8226a47192"
integrity sha512-BZgBJDdX6jyy9hzSTIMRhCsxhF0IlzPr1i98q2wdkDo8rZrbNoBvs+3/Vw+LOIIAFH1G+FyXo5Fjf8qbawGeHg==
dependencies:
"@types/node" "*"

"@types/prettier@^2.1.5":
version "2.7.3"
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.3.tgz#3e51a17e291d01d17d3fc61422015a933af7a08f"
Expand All @@ -4319,6 +4326,13 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb"
integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==

"@types/react-modal@^3.16.3":
version "3.16.3"
resolved "https://registry.yarnpkg.com/@types/react-modal/-/react-modal-3.16.3.tgz#250f32c07f1de28e2bcf9c3e84b56adaa6897013"
integrity sha512-xXuGavyEGaFQDgBv4UVm8/ZsG+qxeQ7f77yNrW3n+1J6XAstUy5rYHeIHPh1KzsGc6IkCIdu6lQ2xWzu1jBTLg==
dependencies:
"@types/react" "*"

"@types/react-redux@^7.1.20":
version "7.1.34"
resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.34.tgz#83613e1957c481521e6776beeac4fd506d11bd0e"
Expand Down