@openapi-generator-plus/generator-common
Advanced tools
Comparing version 0.25.1 to 0.26.0
@@ -0,1 +1,7 @@ | ||
/** | ||
* Extract a config string that may be explicitly set to null, but has a non-null default value. | ||
*/ | ||
export declare function nullableConfigString<T extends string | null | undefined>(config: { | ||
[name: string]: unknown; | ||
}, key: string, defaultValue: T, path?: string): string | null | T; | ||
export declare function configString<T extends string | null | undefined>(config: { | ||
@@ -7,2 +13,5 @@ [name: string]: unknown; | ||
}, key: string, defaultValue: T, path?: string): string[] | T; | ||
export declare function nullableConfigBoolean<T extends boolean | null | undefined>(config: { | ||
[name: string]: unknown; | ||
}, key: string, defaultValue: T, path?: string): boolean | null | T; | ||
export declare function configBoolean<T extends boolean | null | undefined>(config: { | ||
@@ -9,0 +18,0 @@ [name: string]: unknown; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.configObject = exports.configNumber = exports.configBoolean = exports.configStringArray = exports.configString = void 0; | ||
exports.configObject = exports.configNumber = exports.configBoolean = exports.nullableConfigBoolean = exports.configStringArray = exports.configString = exports.nullableConfigString = void 0; | ||
/** | ||
* Extract a config string that may be explicitly set to null, but has a non-null default value. | ||
*/ | ||
function nullableConfigString(config, key, defaultValue, path = '') { | ||
const value = config[key]; | ||
if (value === null) { | ||
return null; | ||
} | ||
return configString(config, key, defaultValue, path); | ||
} | ||
exports.nullableConfigString = nullableConfigString; | ||
function configString(config, key, defaultValue, path = '') { | ||
@@ -31,2 +42,10 @@ const value = config[key]; | ||
exports.configStringArray = configStringArray; | ||
function nullableConfigBoolean(config, key, defaultValue, path = '') { | ||
const value = config[key]; | ||
if (value === null) { | ||
return null; | ||
} | ||
return configBoolean(config, key, defaultValue, path); | ||
} | ||
exports.nullableConfigBoolean = nullableConfigBoolean; | ||
function configBoolean(config, key, defaultValue, path = '') { | ||
@@ -33,0 +52,0 @@ const value = config[key]; |
@@ -1,9 +0,2 @@ | ||
import { CodegenObjectSchema, CodegenProperties, CodegenProperty } from '@openapi-generator-plus/types'; | ||
export { stringify, debugStringify } from '@openapi-generator-plus/core'; | ||
/** | ||
* Return an object containing all of the unique properties, including inherited properties, for a schema, where properties | ||
* in child schemas override any same-named properties in parent schemas. | ||
* @param schemas | ||
* @param result | ||
*/ | ||
export declare function uniquePropertiesIncludingInherited(schemas: CodegenObjectSchema[], result?: CodegenProperties): CodegenProperty[]; | ||
export { uniquePropertiesIncludingInherited, uniquePropertiesIncludingInheritedForParents } from '@openapi-generator-plus/core'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.uniquePropertiesIncludingInherited = exports.debugStringify = exports.stringify = void 0; | ||
const core_1 = require("@openapi-generator-plus/core"); | ||
exports.uniquePropertiesIncludingInheritedForParents = exports.uniquePropertiesIncludingInherited = exports.debugStringify = exports.stringify = void 0; | ||
var core_1 = require("@openapi-generator-plus/core"); | ||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return core_1.stringify; } }); | ||
Object.defineProperty(exports, "debugStringify", { enumerable: true, get: function () { return core_1.debugStringify; } }); | ||
var core_2 = require("@openapi-generator-plus/core"); | ||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return core_2.stringify; } }); | ||
Object.defineProperty(exports, "debugStringify", { enumerable: true, get: function () { return core_2.debugStringify; } }); | ||
/** | ||
* Return an object containing all of the unique properties, including inherited properties, for a schema, where properties | ||
* in child schemas override any same-named properties in parent schemas. | ||
* @param schemas | ||
* @param result | ||
*/ | ||
function uniquePropertiesIncludingInherited(schemas, result = core_1.idx.create()) { | ||
const open = [...schemas]; | ||
for (const schema of open) { | ||
if (schema.properties) { | ||
core_1.idx.merge(result, schema.properties); | ||
} | ||
if (schema.parents) { | ||
for (const aParent of schema.parents) { | ||
if (open.indexOf(aParent) === -1) { | ||
open.push(aParent); | ||
} | ||
} | ||
} | ||
} | ||
return core_1.idx.allValues(result); | ||
} | ||
exports.uniquePropertiesIncludingInherited = uniquePropertiesIncludingInherited; | ||
Object.defineProperty(exports, "uniquePropertiesIncludingInherited", { enumerable: true, get: function () { return core_2.uniquePropertiesIncludingInherited; } }); | ||
Object.defineProperty(exports, "uniquePropertiesIncludingInheritedForParents", { enumerable: true, get: function () { return core_2.uniquePropertiesIncludingInheritedForParents; } }); |
{ | ||
"name": "@openapi-generator-plus/generator-common", | ||
"version": "0.25.1", | ||
"version": "0.26.0", | ||
"description": "Common utilities for openapi-generator-plus generators", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -0,1 +1,12 @@ | ||
/** | ||
* Extract a config string that may be explicitly set to null, but has a non-null default value. | ||
*/ | ||
export function nullableConfigString<T extends string | null | undefined>(config: { [name: string]: unknown }, key: string, defaultValue: T, path = ''): string | null | T { | ||
const value = config[key] | ||
if (value === null) { | ||
return null | ||
} | ||
return configString(config, key, defaultValue, path) | ||
} | ||
export function configString<T extends string | null | undefined>(config: { [name: string]: unknown }, key: string, defaultValue: T, path = ''): string | T { | ||
@@ -28,2 +39,10 @@ const value = config[key] | ||
export function nullableConfigBoolean<T extends boolean | null | undefined>(config: { [name: string]: unknown }, key: string, defaultValue: T, path = ''): boolean | null | T { | ||
const value = config[key] | ||
if (value === null) { | ||
return null | ||
} | ||
return configBoolean(config, key, defaultValue, path) | ||
} | ||
export function configBoolean<T extends boolean | null | undefined>(config: { [name: string]: unknown }, key: string, defaultValue: T, path = ''): boolean | T { | ||
@@ -30,0 +49,0 @@ const value = config[key] |
@@ -1,27 +0,2 @@ | ||
import { CodegenObjectSchema, CodegenProperties, CodegenProperty } from '@openapi-generator-plus/types' | ||
import { idx } from '@openapi-generator-plus/core' | ||
export { stringify, debugStringify } from '@openapi-generator-plus/core' | ||
/** | ||
* Return an object containing all of the unique properties, including inherited properties, for a schema, where properties | ||
* in child schemas override any same-named properties in parent schemas. | ||
* @param schemas | ||
* @param result | ||
*/ | ||
export function uniquePropertiesIncludingInherited(schemas: CodegenObjectSchema[], result: CodegenProperties = idx.create()): CodegenProperty[] { | ||
const open = [...schemas] | ||
for (const schema of open) { | ||
if (schema.properties) { | ||
idx.merge(result, schema.properties) | ||
} | ||
if (schema.parents) { | ||
for (const aParent of schema.parents) { | ||
if (open.indexOf(aParent) === -1) { | ||
open.push(aParent) | ||
} | ||
} | ||
} | ||
} | ||
return idx.allValues(result) | ||
} | ||
export { uniquePropertiesIncludingInherited, uniquePropertiesIncludingInheritedForParents } from '@openapi-generator-plus/core' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37844
594