mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-25 12:54:09 +02:00
fix(openapi): preserve serialized parameter behavior
This commit is contained in:
@@ -494,7 +494,55 @@ mod tests {
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use yaak_models::models::{HttpRequest, HttpUrlParameter};
|
use yaak_models::models::{HttpRequest, HttpRequestHeader, HttpUrlParameter};
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_sendable_request_preserves_independent_cookie_enabled_states() {
|
||||||
|
let request = HttpRequest {
|
||||||
|
url: "https://example.com/api".to_string(),
|
||||||
|
headers: vec![
|
||||||
|
HttpRequestHeader {
|
||||||
|
enabled: true,
|
||||||
|
name: "Cookie".to_string(),
|
||||||
|
value: "session=abc".to_string(),
|
||||||
|
id: None,
|
||||||
|
},
|
||||||
|
HttpRequestHeader {
|
||||||
|
enabled: false,
|
||||||
|
name: "Cookie".to_string(),
|
||||||
|
value: "debug=verbose".to_string(),
|
||||||
|
id: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let sendable =
|
||||||
|
SendableHttpRequest::from_http_request(&request, SendableHttpRequestOptions::default())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(sendable.headers, vec![("Cookie".to_string(), "session=abc".to_string())]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_sendable_request_preserves_serialized_path_delimiters() {
|
||||||
|
let request = HttpRequest {
|
||||||
|
url: "https://example.com/labels/.one%2Ftwo.three/matrix/;x=1%3Bspoof%3D2;y=2"
|
||||||
|
.to_string(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let sendable =
|
||||||
|
SendableHttpRequest::from_http_request(&request, SendableHttpRequestOptions::default())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
sendable.url,
|
||||||
|
"https://example.com/labels/.one%2Ftwo.three/matrix/;x=1%3Bspoof%3D2;y=2",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_build_url_no_params() {
|
fn test_build_url_no_params() {
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ function importOperation({
|
|||||||
useDynamicServerUrls,
|
useDynamicServerUrls,
|
||||||
});
|
});
|
||||||
const urlParameters = [
|
const urlParameters = [
|
||||||
...importUrlParameters({ importState, parameters }),
|
...importUrlParameters({ importState, parameters, path }),
|
||||||
...authentication.urlParameters,
|
...authentication.urlParameters,
|
||||||
];
|
];
|
||||||
const headers = mergeHeaders(
|
const headers = mergeHeaders(
|
||||||
@@ -336,6 +336,8 @@ function importOperation({
|
|||||||
url: buildOperationUrl(
|
url: buildOperationUrl(
|
||||||
operationBaseUrl({ operation, pathItem, requestBaseUrl, serverOverrides }),
|
operationBaseUrl({ operation, pathItem, requestBaseUrl, serverOverrides }),
|
||||||
path,
|
path,
|
||||||
|
parameters,
|
||||||
|
importState,
|
||||||
),
|
),
|
||||||
urlParameters,
|
urlParameters,
|
||||||
headers,
|
headers,
|
||||||
@@ -645,8 +647,56 @@ function findOrCreateFolderId({
|
|||||||
return folder.id;
|
return folder.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildOperationUrl(baseUrl: string, path: string): string {
|
function buildOperationUrl(
|
||||||
return joinUrlParts(baseUrl, path.replaceAll(/{([^}/]+)}/g, ":$1"));
|
baseUrl: string,
|
||||||
|
path: string,
|
||||||
|
parameters: unknown[],
|
||||||
|
importState: ImportState,
|
||||||
|
): string {
|
||||||
|
let serializedPath = path;
|
||||||
|
for (const rawParameter of parameters) {
|
||||||
|
const parameter = importState.resolve(rawParameter);
|
||||||
|
if (!isRecord(parameter) || !shouldInlinePathParameter(parameter, importState, path)) continue;
|
||||||
|
|
||||||
|
const name = stringAt(parameter, "name") ?? "";
|
||||||
|
if (name.length === 0) continue;
|
||||||
|
const value = parameterExampleValue(parameter, importState);
|
||||||
|
serializedPath = serializedPath.replaceAll(
|
||||||
|
`{${name}}`,
|
||||||
|
isRecord(parameter.content)
|
||||||
|
? encodePathComponent(serializeContentParameter(parameter, importState))
|
||||||
|
: serializePathParameter(name, value, parameter, encodePathComponent),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return joinUrlParts(baseUrl, serializedPath.replaceAll(/{([^}/]+)}/g, ":$1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldInlinePathParameter(
|
||||||
|
parameter: UnknownRecord,
|
||||||
|
importState: ImportState,
|
||||||
|
path: string,
|
||||||
|
): boolean {
|
||||||
|
if (stringAt(parameter, "in") !== "path") return false;
|
||||||
|
const name = stringAt(parameter, "name") ?? "";
|
||||||
|
const template = `{${name}}`;
|
||||||
|
const matchingSegments = path.split("/").filter((segment) => segment.includes(template));
|
||||||
|
if (matchingSegments.length === 0 || matchingSegments.some((segment) => segment !== template)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (isRecord(parameter.content)) return false;
|
||||||
|
const value = parameterExampleValue(parameter, importState);
|
||||||
|
return (
|
||||||
|
stringAt(parameter, "style") === "matrix" ||
|
||||||
|
Array.isArray(value) ||
|
||||||
|
isRecord(value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function encodePathComponent(value: unknown): string {
|
||||||
|
return encodeURIComponent(stringifyExampleValue(value)).replace(
|
||||||
|
/[!'()*]/g,
|
||||||
|
(character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function importBaseUrl(spec: UnknownRecord): string {
|
function importBaseUrl(spec: UnknownRecord): string {
|
||||||
@@ -733,21 +783,24 @@ function trimTrailingSlashes(value: string): string {
|
|||||||
function importUrlParameters({
|
function importUrlParameters({
|
||||||
importState,
|
importState,
|
||||||
parameters,
|
parameters,
|
||||||
|
path,
|
||||||
}: {
|
}: {
|
||||||
importState: ImportState;
|
importState: ImportState;
|
||||||
parameters: unknown[];
|
parameters: unknown[];
|
||||||
|
path: string;
|
||||||
}): HttpUrlParameter[] {
|
}): HttpUrlParameter[] {
|
||||||
return parameters
|
return parameters
|
||||||
.map((p) => importState.resolve(p))
|
.map((p) => importState.resolve(p))
|
||||||
.filter(isRecord)
|
.filter(isRecord)
|
||||||
.filter((p) => stringAt(p, "in") === "query" || stringAt(p, "in") === "path")
|
.filter((p) => stringAt(p, "in") === "query" || stringAt(p, "in") === "path")
|
||||||
.flatMap((p) => serializeUrlParameter(p, importState))
|
.flatMap((p) => serializeUrlParameter(p, importState, path))
|
||||||
.filter(({ name }) => name.length > 0);
|
.filter(({ name }) => name.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeUrlParameter(
|
function serializeUrlParameter(
|
||||||
parameter: UnknownRecord,
|
parameter: UnknownRecord,
|
||||||
importState: ImportState,
|
importState: ImportState,
|
||||||
|
path: string,
|
||||||
): HttpUrlParameter[] {
|
): HttpUrlParameter[] {
|
||||||
const name = stringAt(parameter, "name") ?? "";
|
const name = stringAt(parameter, "name") ?? "";
|
||||||
const location = stringAt(parameter, "in");
|
const location = stringAt(parameter, "in");
|
||||||
@@ -763,6 +816,7 @@ function serializeUrlParameter(
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (location === "path") {
|
if (location === "path") {
|
||||||
|
if (shouldInlinePathParameter(parameter, importState, path)) return [];
|
||||||
return [{ enabled, name: `:${name}`, value: serializePathParameter(name, value, parameter) }];
|
return [{ enabled, name: `:${name}`, value: serializePathParameter(name, value, parameter) }];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,24 +886,39 @@ function importHeaderParameters({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function importCookieHeader(parameters: unknown[], importState: ImportState): HttpRequestHeader[] {
|
function importCookieHeader(parameters: unknown[], importState: ImportState): HttpRequestHeader[] {
|
||||||
const cookies = parameters
|
return parameters
|
||||||
.map((p) => importState.resolve(p))
|
.map((p) => importState.resolve(p))
|
||||||
.filter(isRecord)
|
.filter(isRecord)
|
||||||
.filter((p) => stringAt(p, "in") === "cookie")
|
.filter((p) => stringAt(p, "in") === "cookie")
|
||||||
.map((p) => ({
|
.map((p) => ({
|
||||||
enabled: p.required === true,
|
enabled: p.required === true,
|
||||||
name: stringAt(p, "name") ?? "",
|
|
||||||
value: serializeParameterValue(p, importState),
|
|
||||||
}))
|
|
||||||
.filter(({ name }) => name.length > 0);
|
|
||||||
if (cookies.length === 0) return [];
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
enabled: cookies.some(({ enabled }) => enabled),
|
|
||||||
name: "Cookie",
|
name: "Cookie",
|
||||||
value: cookies.map(({ name, value }) => `${name}=${value}`).join("; "),
|
value: serializeCookieParameter(p, importState),
|
||||||
},
|
}))
|
||||||
];
|
.filter(({ value }) => value.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function serializeCookieParameter(parameter: UnknownRecord, importState: ImportState): string {
|
||||||
|
const name = stringAt(parameter, "name") ?? "";
|
||||||
|
if (name.length === 0) return "";
|
||||||
|
if (isRecord(parameter.content)) {
|
||||||
|
return `${name}=${serializeContentParameter(parameter, importState)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = parameterExampleValue(parameter, importState);
|
||||||
|
const explode = parameter.explode !== false;
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return explode
|
||||||
|
? value.map((entryValue) => `${name}=${stringifyExampleValue(entryValue)}`).join("&")
|
||||||
|
: `${name}=${value.map(stringifyExampleValue).join(",")}`;
|
||||||
|
}
|
||||||
|
if (isRecord(value)) {
|
||||||
|
const entries = Object.entries(value);
|
||||||
|
return explode
|
||||||
|
? entries.map(([key, entryValue]) => `${key}=${stringifyExampleValue(entryValue)}`).join("&")
|
||||||
|
: `${name}=${entries.flat().map(stringifyExampleValue).join(",")}`;
|
||||||
|
}
|
||||||
|
return `${name}=${stringifyExampleValue(value)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeParameterValue(parameter: UnknownRecord, importState: ImportState): string {
|
function serializeParameterValue(parameter: UnknownRecord, importState: ImportState): string {
|
||||||
@@ -865,49 +934,60 @@ function serializeContentParameter(parameter: UnknownRecord, importState: Import
|
|||||||
: stringifyExampleValue(value);
|
: stringifyExampleValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializePathParameter(name: string, value: unknown, parameter: UnknownRecord): string {
|
function serializePathParameter(
|
||||||
|
name: string,
|
||||||
|
value: unknown,
|
||||||
|
parameter: UnknownRecord,
|
||||||
|
serializeValue: (value: unknown) => string = stringifyExampleValue,
|
||||||
|
): string {
|
||||||
const style = stringAt(parameter, "style") ?? "simple";
|
const style = stringAt(parameter, "style") ?? "simple";
|
||||||
const explode = parameter.explode === true;
|
const explode = parameter.explode === true;
|
||||||
const values = Array.isArray(value)
|
const values = Array.isArray(value)
|
||||||
? value.map(stringifyExampleValue)
|
? value.map(serializeValue)
|
||||||
: isRecord(value)
|
: isRecord(value)
|
||||||
? Object.entries(value).flatMap(([key, entryValue]) => [
|
? Object.entries(value).flatMap(([key, entryValue]) => [
|
||||||
key,
|
serializeValue(key),
|
||||||
stringifyExampleValue(entryValue),
|
serializeValue(entryValue),
|
||||||
])
|
])
|
||||||
: [stringifyExampleValue(value)];
|
: [serializeValue(value)];
|
||||||
|
|
||||||
if (style === "label") {
|
if (style === "label") {
|
||||||
if (explode && isRecord(value)) {
|
if (explode && isRecord(value)) {
|
||||||
return `.${Object.entries(value)
|
return `.${Object.entries(value)
|
||||||
.map(([key, entryValue]) => `${key}=${stringifyExampleValue(entryValue)}`)
|
.map(([key, entryValue]) => `${serializeValue(key)}=${serializeValue(entryValue)}`)
|
||||||
.join(".")}`;
|
.join(".")}`;
|
||||||
}
|
}
|
||||||
return `.${values.join(explode ? "." : ",")}`;
|
return `.${values.join(explode ? "." : ",")}`;
|
||||||
}
|
}
|
||||||
if (style === "matrix") {
|
if (style === "matrix") {
|
||||||
if (explode && Array.isArray(value)) {
|
if (explode && Array.isArray(value)) {
|
||||||
return value.map((entryValue) => `;${name}=${stringifyExampleValue(entryValue)}`).join("");
|
return value.map((entryValue) => `;${name}=${serializeValue(entryValue)}`).join("");
|
||||||
}
|
}
|
||||||
if (explode && isRecord(value)) {
|
if (explode && isRecord(value)) {
|
||||||
return Object.entries(value)
|
return Object.entries(value)
|
||||||
.map(([key, entryValue]) => `;${key}=${stringifyExampleValue(entryValue)}`)
|
.map(([key, entryValue]) => `;${serializeValue(key)}=${serializeValue(entryValue)}`)
|
||||||
.join("");
|
.join("");
|
||||||
}
|
}
|
||||||
return `;${name}=${values.join(",")}`;
|
return `;${name}=${values.join(",")}`;
|
||||||
}
|
}
|
||||||
return serializeSimpleParameter(value, parameter);
|
return serializeSimpleParameter(value, parameter, serializeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeSimpleParameter(value: unknown, parameter: UnknownRecord): string {
|
function serializeSimpleParameter(
|
||||||
if (Array.isArray(value)) return value.map(stringifyExampleValue).join(",");
|
value: unknown,
|
||||||
|
parameter: UnknownRecord,
|
||||||
|
serializeValue: (value: unknown) => string = stringifyExampleValue,
|
||||||
|
): string {
|
||||||
|
if (Array.isArray(value)) return value.map(serializeValue).join(",");
|
||||||
if (isRecord(value)) {
|
if (isRecord(value)) {
|
||||||
const entries = Object.entries(value);
|
const entries = Object.entries(value);
|
||||||
return parameter.explode === true
|
return parameter.explode === true
|
||||||
? entries.map(([key, entryValue]) => `${key}=${stringifyExampleValue(entryValue)}`).join(",")
|
? entries
|
||||||
: entries.flat().map(stringifyExampleValue).join(",");
|
.map(([key, entryValue]) => `${serializeValue(key)}=${serializeValue(entryValue)}`)
|
||||||
|
.join(",")
|
||||||
|
: entries.flat().map(serializeValue).join(",");
|
||||||
}
|
}
|
||||||
return stringifyExampleValue(value);
|
return serializeValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parameterExample(parameter: UnknownRecord, importState: ImportState): string {
|
function parameterExample(parameter: UnknownRecord, importState: ImportState): string {
|
||||||
@@ -1521,10 +1601,12 @@ function buildOAuthVariablesByScheme(
|
|||||||
|
|
||||||
function mergeHeaders(...headerGroups: HttpRequestHeader[][]): HttpRequestHeader[] {
|
function mergeHeaders(...headerGroups: HttpRequestHeader[][]): HttpRequestHeader[] {
|
||||||
const headers: HttpRequestHeader[] = [];
|
const headers: HttpRequestHeader[] = [];
|
||||||
for (const header of headerGroups.flat()) {
|
for (const group of headerGroups) {
|
||||||
const existing = headers.find((h) => h.name.toLowerCase() === header.name.toLowerCase());
|
const namesFromEarlierGroups = new Set(headers.map((header) => header.name.toLowerCase()));
|
||||||
if (existing == null) {
|
for (const header of group) {
|
||||||
headers.push(header);
|
if (!namesFromEarlierGroups.has(header.name.toLowerCase())) {
|
||||||
|
headers.push(header);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return headers;
|
return headers;
|
||||||
|
|||||||
@@ -163,18 +163,13 @@ Responses:
|
|||||||
"model": "http_request",
|
"model": "http_request",
|
||||||
"name": "Retrieve one version of a particular API",
|
"name": "Retrieve one version of a particular API",
|
||||||
"sortPriority": 5,
|
"sortPriority": 5,
|
||||||
"url": "\${[baseUrl]}/specs/:provider/:api.json",
|
"url": "\${[baseUrl]}/specs/:provider/2.1.0.json",
|
||||||
"urlParameters": [
|
"urlParameters": [
|
||||||
{
|
{
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"name": ":provider",
|
"name": ":provider",
|
||||||
"value": "apis.guru",
|
"value": "apis.guru",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"enabled": true,
|
|
||||||
"name": ":api",
|
|
||||||
"value": "2.1.0",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||||
},
|
},
|
||||||
@@ -207,7 +202,7 @@ Responses:
|
|||||||
"model": "http_request",
|
"model": "http_request",
|
||||||
"name": "Retrieve one version of a particular API with a serviceName.",
|
"name": "Retrieve one version of a particular API with a serviceName.",
|
||||||
"sortPriority": 6,
|
"sortPriority": 6,
|
||||||
"url": "\${[baseUrl]}/specs/:provider/:service/:api.json",
|
"url": "\${[baseUrl]}/specs/:provider/:service/2.1.0.json",
|
||||||
"urlParameters": [
|
"urlParameters": [
|
||||||
{
|
{
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
@@ -219,11 +214,6 @@ Responses:
|
|||||||
"name": ":service",
|
"name": ":service",
|
||||||
"value": "graph",
|
"value": "graph",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"enabled": true,
|
|
||||||
"name": ":api",
|
|
||||||
"value": "2.1.0",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||||
},
|
},
|
||||||
@@ -256,14 +246,8 @@ Responses:
|
|||||||
"model": "http_request",
|
"model": "http_request",
|
||||||
"name": "List all APIs for a particular provider",
|
"name": "List all APIs for a particular provider",
|
||||||
"sortPriority": 7,
|
"sortPriority": 7,
|
||||||
"url": "\${[baseUrl]}/:provider.json",
|
"url": "\${[baseUrl]}/apis.guru.json",
|
||||||
"urlParameters": [
|
"urlParameters": [],
|
||||||
{
|
|
||||||
"enabled": true,
|
|
||||||
"name": ":provider",
|
|
||||||
"value": "apis.guru",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -781,6 +781,11 @@ describe("importer-openapi", () => {
|
|||||||
required: true,
|
required: true,
|
||||||
schema: { type: "string", example: "abc" },
|
schema: { type: "string", example: "abc" },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "debug",
|
||||||
|
in: "cookie",
|
||||||
|
schema: { type: "string", example: "verbose" },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "X-Filter",
|
name: "X-Filter",
|
||||||
in: "header",
|
in: "header",
|
||||||
@@ -798,6 +803,7 @@ describe("importer-openapi", () => {
|
|||||||
expect(imported?.resources.httpRequests[0]?.headers).toEqual([
|
expect(imported?.resources.httpRequests[0]?.headers).toEqual([
|
||||||
{ enabled: true, name: "X-Filter", value: "active" },
|
{ enabled: true, name: "X-Filter", value: "active" },
|
||||||
{ enabled: true, name: "Cookie", value: "session=abc" },
|
{ enabled: true, name: "Cookie", value: "session=abc" },
|
||||||
|
{ enabled: false, name: "Cookie", value: "debug=verbose" },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -847,13 +853,13 @@ describe("importer-openapi", () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Serializes label and matrix path parameters", async () => {
|
test("Emits executable label and matrix path serializations", async () => {
|
||||||
const imported = await convertOpenApi(
|
const imported = await convertOpenApi(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
openapi: "3.0.4",
|
openapi: "3.0.4",
|
||||||
info: { title: "Path Serialization Test", version: "1.0.0" },
|
info: { title: "Path Serialization Test", version: "1.0.0" },
|
||||||
paths: {
|
paths: {
|
||||||
"/labels/{labels}/matrix/{coordinates}": {
|
"/labels/{labels}/matrix/{coordinates}/report.{format}": {
|
||||||
get: {
|
get: {
|
||||||
parameters: [
|
parameters: [
|
||||||
{
|
{
|
||||||
@@ -862,7 +868,7 @@ describe("importer-openapi", () => {
|
|||||||
required: true,
|
required: true,
|
||||||
style: "label",
|
style: "label",
|
||||||
explode: true,
|
explode: true,
|
||||||
schema: { type: "array", example: ["one", "two"] },
|
schema: { type: "array", example: ["one/two", "three"] },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "coordinates",
|
name: "coordinates",
|
||||||
@@ -870,7 +876,13 @@ describe("importer-openapi", () => {
|
|||||||
required: true,
|
required: true,
|
||||||
style: "matrix",
|
style: "matrix",
|
||||||
explode: true,
|
explode: true,
|
||||||
schema: { type: "object", example: { x: 1, y: 2 } },
|
schema: { type: "object", example: { x: "1;spoof=2", y: 2 } },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "format",
|
||||||
|
in: "path",
|
||||||
|
required: true,
|
||||||
|
schema: { type: "string", example: "json/evil" },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
responses: {},
|
responses: {},
|
||||||
@@ -880,10 +892,12 @@ describe("importer-openapi", () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(imported?.resources.httpRequests[0]?.urlParameters).toEqual([
|
expect(imported?.resources.httpRequests[0]).toEqual(
|
||||||
{ enabled: true, name: ":labels", value: ".one.two" },
|
expect.objectContaining({
|
||||||
{ enabled: true, name: ":coordinates", value: ";x=1;y=2" },
|
url: "${[baseUrl]}/labels/.one%2Ftwo.three/matrix/;x=1%3Bspoof%3D2;y=2/report.json%2Fevil",
|
||||||
]);
|
urlParameters: [],
|
||||||
|
}),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Prefers operation-level consumes for Swagger bodies", async () => {
|
test("Prefers operation-level consumes for Swagger bodies", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user