|
8 | 8 | import React, { useEffect, useState } from "react";
|
9 | 9 |
|
10 | 10 | import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
| 11 | +import { Postman } from "@har-sdk/core"; |
11 | 12 | import { postman2har } from "@har-sdk/postman";
|
12 | 13 | import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
|
13 | 14 | import buildPostmanRequest from "@theme/ApiExplorer/buildPostmanRequest";
|
14 | 15 | import CodeTabs from "@theme/ApiExplorer/CodeTabs";
|
15 | 16 | import { useTypedSelector } from "@theme/ApiItem/hooks";
|
16 |
| -import HTTPSnippet from "httpsnippet-lite"; |
| 17 | +import { HTTPSnippet, TargetId } from "httpsnippet-lite"; |
17 | 18 | import cloneDeep from "lodash/cloneDeep";
|
18 | 19 | import * as sdk from "postman-collection";
|
19 | 20 |
|
@@ -165,9 +166,15 @@ function CodeSnippets({
|
165 | 166 | const collection = new sdk.Collection({
|
166 | 167 | item: [{ name: "request", request: cleanedPostmanRequest }],
|
167 | 168 | });
|
168 |
| - const [harRequest] = await postman2har(collection.toJSON()); |
169 |
| - const snippet = new HTTPSnippet(harRequest).convert( |
170 |
| - mergedLanguage.language, |
| 169 | + const [harRequest] = await postman2har({ |
| 170 | + ...collection.toJSON(), |
| 171 | + info: { |
| 172 | + schema: |
| 173 | + "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", |
| 174 | + }, |
| 175 | + } as Postman.Document); |
| 176 | + const snippet = await new HTTPSnippet(harRequest).convert( |
| 177 | + mergedLanguage.language as TargetId, |
171 | 178 | mergedLanguage.variant,
|
172 | 179 | mergedLanguage.options
|
173 | 180 | );
|
@@ -201,9 +208,15 @@ function CodeSnippets({
|
201 | 208 | const collection = new sdk.Collection({
|
202 | 209 | item: [{ name: "request", request: cleanedPostmanRequest }],
|
203 | 210 | });
|
204 |
| - const [harRequest] = await postman2har(collection.toJSON()); |
205 |
| - const snippet = new HTTPSnippet(harRequest).convert( |
206 |
| - mergedLanguage.language, |
| 211 | + const [harRequest] = await postman2har({ |
| 212 | + ...collection.toJSON(), |
| 213 | + info: { |
| 214 | + schema: |
| 215 | + "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", |
| 216 | + }, |
| 217 | + } as Postman.Document); |
| 218 | + const snippet = await new HTTPSnippet(harRequest).convert( |
| 219 | + mergedLanguage.language as TargetId, |
207 | 220 | selectedVariant,
|
208 | 221 | mergedLanguage.options
|
209 | 222 | );
|
|
0 commit comments