Skip to content

Commit

Permalink
Update swagger-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
tmo207 committed Oct 30, 2023
1 parent 4f88e41 commit 5fc776b
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 199 deletions.
320 changes: 141 additions & 179 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"author": "Jason Rametta",
"license": "Apache-2.0",
"dependencies": {
"@apidevtools/swagger-parser": "^10.1.0",
"axios": "^1.5.1",
"commander": "^11.1.0",
"swagger-parser": "^10.0.3",
"typescript": "^5.2.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/common/queryKeys.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import type { OpenAPIV3 } from "openapi-types";
import { normalizeOperationId, createParams } from "./util";
import SwaggerParser from "swagger-parser";
import SwaggerParser from "@apidevtools/swagger-parser";

const NULL_IF_UNDEFINED_FN_NAME = "nullIfUndefined";

Expand Down
31 changes: 17 additions & 14 deletions src/common/requests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ts, { PropertyAssignment } from "typescript";
import type SwaggerParser from "swagger-parser";
import type SwaggerParser from "@apidevtools/swagger-parser";
import type { OpenAPIV3 } from "openapi-types";
import {
schemaObjectOrRefType,
Expand Down Expand Up @@ -436,7 +436,9 @@ function makeRequest(
? item.requestBody
: ($refs.get(item.requestBody.$ref) as OpenAPIV3.RequestBodyObject);

const contentTypeConfig = tryCreateContentTypeAssignment(Object.keys(reqBody.content))
const contentTypeConfig = tryCreateContentTypeAssignment(
Object.keys(reqBody.content)
);
axiosConfigFields.push(...contentTypeConfig);
}

Expand Down Expand Up @@ -589,24 +591,25 @@ export function replacePattern(pattern: string, replacers: string[]) {
);
}


function tryCreateContentTypeAssignment(contentTypeKeys: string[]): PropertyAssignment[] {
function tryCreateContentTypeAssignment(
contentTypeKeys: string[]
): PropertyAssignment[] {
if (!contentTypeKeys.length) {
return []
return [];
}

const propertyAssignment = ts.factory.createPropertyAssignment(
/*name*/ ts.factory.createIdentifier("headers"),
/*initializer*/ ts.factory.createObjectLiteralExpression(
/*properties*/ [
ts.factory.createPropertyAssignment(
/*name*/ ts.factory.createStringLiteral(`Content-Type`),
/*initializer*/ ts.factory.createStringLiteral(contentTypeKeys[0])
),
],
/*multiline*/ true
/*properties*/ [
ts.factory.createPropertyAssignment(
/*name*/ ts.factory.createStringLiteral(`Content-Type`),
/*initializer*/ ts.factory.createStringLiteral(contentTypeKeys[0])
),
],
/*multiline*/ true
)
);

return [propertyAssignment]
return [propertyAssignment];
}
2 changes: 1 addition & 1 deletion src/common/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import type { OpenAPI, OpenAPIV3 } from "openapi-types";
import { createLiteralNodeFromProperties } from "./types";
import type SwaggerParser from "swagger-parser";
import type SwaggerParser from "@apidevtools/swagger-parser";

export function isOpenApiV3Document(
doc: OpenAPI.Document
Expand Down
2 changes: 1 addition & 1 deletion src/react-query/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ts from "typescript";
import type { OpenAPIV3 } from "openapi-types";
import SwaggerParser from "swagger-parser";
import SwaggerParser from "@apidevtools/swagger-parser";
import {
capitalizeFirstLetter,
normalizeOperationId,
Expand Down
2 changes: 1 addition & 1 deletion src/react-query/queries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ts from "typescript";
import type { OpenAPIV3 } from "openapi-types";
import SwaggerParser from "swagger-parser";
import SwaggerParser from "@apidevtools/swagger-parser";
import {
capitalizeFirstLetter,
createParams,
Expand Down
2 changes: 1 addition & 1 deletion src/swr/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
createParams,
normalizeOperationId,
} from "../common/util";
import SwaggerParser from "swagger-parser";
import SwaggerParser from "@apidevtools/swagger-parser";

export function makeQueries(
$refs: SwaggerParser.$Refs,
Expand Down

0 comments on commit 5fc776b

Please sign in to comment.