@povio/openapi-codegen-cli 3.0.0-rc.11 → 3.0.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as Profiler, h as deepMerge, i as writeGenerateFileData, p as DEFAULT_GENERATE_OPTIONS, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-
|
|
1
|
+
import { S as Profiler, h as deepMerge, i as writeGenerateFileData, p as DEFAULT_GENERATE_OPTIONS, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-RllueTvG.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
4
4
|
|
package/dist/{generateCodeFromOpenAPIDoc-mALUMd3q.mjs → generateCodeFromOpenAPIDoc-RllueTvG.mjs}
RENAMED
|
@@ -1988,7 +1988,8 @@ const getEndpointBody$1 = (endpoint) => endpoint.parameters.find((param) => para
|
|
|
1988
1988
|
const hasEndpointConfig = (endpoint, resolver) => {
|
|
1989
1989
|
const endpointConfig = getEndpointConfig(endpoint);
|
|
1990
1990
|
const hasAxiosRequestConfig = resolver.options.axiosRequestConfig;
|
|
1991
|
-
|
|
1991
|
+
const needsBlobConfig = endpoint.mediaDownload || endpoint.response === "z.instanceof(Blob)";
|
|
1992
|
+
return Object.keys(endpointConfig).length > 0 || hasAxiosRequestConfig || needsBlobConfig;
|
|
1992
1993
|
};
|
|
1993
1994
|
const getEndpointPath = (endpoint) => endpoint.path.replace(/:([a-zA-Z0-9_]+)/g, "${$1}");
|
|
1994
1995
|
function mapEndpointParamsToFunctionParams(resolver, endpoint, options) {
|
|
@@ -2365,7 +2366,7 @@ function getEndpointsFromOpenAPIDoc(resolver) {
|
|
|
2365
2366
|
}) ?? mediaTypes.find(isMediaTypeAllowed);
|
|
2366
2367
|
let schema;
|
|
2367
2368
|
if (matchingMediaType) {
|
|
2368
|
-
endpoint.responseFormat = matchingMediaType;
|
|
2369
|
+
if (isMainResponseStatus(Number(statusCode)) || statusCode === "default" && !endpoint.responseFormat) endpoint.responseFormat = matchingMediaType;
|
|
2369
2370
|
schema = responseObj.content?.[matchingMediaType]?.schema;
|
|
2370
2371
|
} else if (statusCode === "200") resolver.validationErrors.push(getInvalidStatusCodeError({
|
|
2371
2372
|
received: "200",
|
|
@@ -2409,7 +2410,7 @@ function getEndpointsFromOpenAPIDoc(resolver) {
|
|
|
2409
2410
|
const domainStr = rawSchema["x-domain-error-domain"];
|
|
2410
2411
|
const domainName = rawSchema["x-domain-error-name"];
|
|
2411
2412
|
const codeEnumArr = ((rawSchema?.properties)?.code)?.enum;
|
|
2412
|
-
const domainCode = Array.isArray(codeEnumArr) && codeEnumArr.length === 1 && typeof codeEnumArr[0] === "number" ? codeEnumArr[0] : void 0;
|
|
2413
|
+
const domainCode = Array.isArray(codeEnumArr) && codeEnumArr.length === 1 && (typeof codeEnumArr[0] === "number" || typeof codeEnumArr[0] === "string") ? codeEnumArr[0] : void 0;
|
|
2413
2414
|
endpoint.errors.push({
|
|
2414
2415
|
zodSchema: responseZodSchema,
|
|
2415
2416
|
status,
|
|
@@ -3913,7 +3914,8 @@ function getSortingPresenceChain$1(resolver, param) {
|
|
|
3913
3914
|
function renderEndpointConfig(resolver, endpoint, modelNamespaceTag) {
|
|
3914
3915
|
const endpointConfig = getEndpointConfig(endpoint);
|
|
3915
3916
|
const hasAxiosRequestConfig = resolver.options.axiosRequestConfig;
|
|
3916
|
-
|
|
3917
|
+
const needsBlobConfig = endpoint.mediaDownload || endpoint.response === "z.instanceof(Blob)";
|
|
3918
|
+
if (Object.keys(endpointConfig).length === 0 && !needsBlobConfig) return hasAxiosRequestConfig ? AXIOS_REQUEST_CONFIG_NAME : "";
|
|
3917
3919
|
const lines = [];
|
|
3918
3920
|
lines.push("{");
|
|
3919
3921
|
if (hasAxiosRequestConfig) lines.push(` ...${AXIOS_REQUEST_CONFIG_NAME},`);
|
|
@@ -4457,7 +4459,8 @@ function getSortingPresenceChain(resolver, param) {
|
|
|
4457
4459
|
function renderInlineEndpointConfig(resolver, endpoint, modelNamespaceTag) {
|
|
4458
4460
|
const endpointConfig = getEndpointConfig(endpoint);
|
|
4459
4461
|
const hasAxiosRequestConfig = resolver.options.axiosRequestConfig;
|
|
4460
|
-
|
|
4462
|
+
const needsBlobConfig = endpoint.mediaDownload || endpoint.response === "z.instanceof(Blob)";
|
|
4463
|
+
if (Object.keys(endpointConfig).length === 0 && !needsBlobConfig) return hasAxiosRequestConfig ? AXIOS_REQUEST_CONFIG_NAME : "";
|
|
4461
4464
|
const lines = [];
|
|
4462
4465
|
lines.push("{");
|
|
4463
4466
|
if (hasAxiosRequestConfig) lines.push(` ...${AXIOS_REQUEST_CONFIG_NAME},`);
|
|
@@ -4807,6 +4810,7 @@ export const ${APP_REST_CLIENT_NAME} = new RestClient({
|
|
|
4807
4810
|
function domainToPascalCase(domain) {
|
|
4808
4811
|
return domain.split(/[-_]/).map(capitalize).join("");
|
|
4809
4812
|
}
|
|
4813
|
+
const VALID_IDENTIFIER = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
4810
4814
|
function generateDomainErrors({ data }) {
|
|
4811
4815
|
const byDomain = /* @__PURE__ */ new Map();
|
|
4812
4816
|
for (const { endpoints } of data.values()) for (const endpoint of endpoints) for (const error of endpoint.errors) {
|
|
@@ -4824,8 +4828,16 @@ function generateDomainErrors({ data }) {
|
|
|
4824
4828
|
const blocks = [];
|
|
4825
4829
|
for (const [domain, codes] of [...byDomain.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
4826
4830
|
const pascalName = domainToPascalCase(domain);
|
|
4827
|
-
const entries = [...codes.values()].sort((a, b) =>
|
|
4828
|
-
|
|
4831
|
+
const entries = [...codes.values()].sort((a, b) => {
|
|
4832
|
+
if (typeof a.code === "number" && typeof b.code === "number") return a.code - b.code;
|
|
4833
|
+
const sa = String(a.code);
|
|
4834
|
+
const sb = String(b.code);
|
|
4835
|
+
return sa < sb ? -1 : sa > sb ? 1 : 0;
|
|
4836
|
+
}).map(({ code, name, description }) => {
|
|
4837
|
+
const comment = description ? ` /** ${description} */\n ` : " ";
|
|
4838
|
+
const key = name ?? (typeof code === "string" ? code : `ERROR_${code}`);
|
|
4839
|
+
if (!VALID_IDENTIFIER.test(key)) throw new Error(`Domain error code "${code}" produces an invalid identifier "${key}". Use the 'name' field on @ApiDomainErrorResponse to provide a valid identifier.`);
|
|
4840
|
+
return `${comment}${key}: ${typeof code === "string" ? `"${code}"` : String(code)}`;
|
|
4829
4841
|
}).join(",\n");
|
|
4830
4842
|
blocks.push(`export const ${pascalName}DomainErrors = {\n${entries},\n} as const;`);
|
|
4831
4843
|
blocks.push(`export type ${pascalName}DomainErrorCode = (typeof ${pascalName}DomainErrors)[keyof typeof ${pascalName}DomainErrors];`);
|
package/dist/generator.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as getNamespaceName, a as getDataFromOpenAPIDoc, b as isParamMediaTypeAllowed, c as getSchemaTsMetaType, d as getTagImportPath, f as getQueryName, g as invalidVariableNameCharactersToCamel, l as getTsTypeBase, o as isMutation, p as DEFAULT_GENERATE_OPTIONS, s as isQuery, t as generateCodeFromOpenAPIDoc, v as GenerateType, x as formatTag, y as isMediaTypeAllowed } from "./generateCodeFromOpenAPIDoc-
|
|
1
|
+
import { _ as getNamespaceName, a as getDataFromOpenAPIDoc, b as isParamMediaTypeAllowed, c as getSchemaTsMetaType, d as getTagImportPath, f as getQueryName, g as invalidVariableNameCharactersToCamel, l as getTsTypeBase, o as isMutation, p as DEFAULT_GENERATE_OPTIONS, s as isQuery, t as generateCodeFromOpenAPIDoc, v as GenerateType, x as formatTag, y as isMediaTypeAllowed } from "./generateCodeFromOpenAPIDoc-RllueTvG.mjs";
|
|
2
2
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/core/getMetadataFromOpenAPIDoc.ts
|
package/dist/sh.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as VALIDATION_ERROR_TYPE_TITLE, S as Profiler, a as getDataFromOpenAPIDoc, m as groupByType, n as getOutputFileName, u as getTagFileName, v as GenerateType } from "./generateCodeFromOpenAPIDoc-
|
|
3
|
-
import { n as resolveConfig, t as runGenerate } from "./generate.runner-
|
|
2
|
+
import { C as VALIDATION_ERROR_TYPE_TITLE, S as Profiler, a as getDataFromOpenAPIDoc, m as groupByType, n as getOutputFileName, u as getTagFileName, v as GenerateType } from "./generateCodeFromOpenAPIDoc-RllueTvG.mjs";
|
|
3
|
+
import { n as resolveConfig, t as runGenerate } from "./generate.runner-2HwNX9i1.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import yargs from "yargs";
|
|
6
6
|
import { hideBin } from "yargs/helpers";
|
|
@@ -39,7 +39,7 @@ function logBanner(message) {
|
|
|
39
39
|
* Fetch the version from package.json
|
|
40
40
|
*/
|
|
41
41
|
function getVersion() {
|
|
42
|
-
return "3.0.0-rc.
|
|
42
|
+
return "3.0.0-rc.13";
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
//#endregion
|
package/dist/vite.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Profiler } from "./generateCodeFromOpenAPIDoc-
|
|
2
|
-
import { t as runGenerate } from "./generate.runner-
|
|
1
|
+
import { S as Profiler } from "./generateCodeFromOpenAPIDoc-RllueTvG.mjs";
|
|
2
|
+
import { t as runGenerate } from "./generate.runner-2HwNX9i1.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
|
|
5
5
|
//#region src/vite/openapi-codegen.plugin.ts
|