@kubb/oas 4.15.1 → 4.15.2
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.
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/utils.ts +29 -0
package/dist/index.d.cts
CHANGED
|
@@ -692,6 +692,7 @@ declare function isDiscriminator(obj?: any): obj is SchemaObject$1 & {
|
|
|
692
692
|
* @returns True if the schema is required; otherwise, false.
|
|
693
693
|
*/
|
|
694
694
|
declare function isRequired(schema?: SchemaObject$1): boolean;
|
|
695
|
+
declare function isAllOptional(schema: unknown): boolean;
|
|
695
696
|
declare function isOptional(schema?: SchemaObject$1): boolean;
|
|
696
697
|
declare function parse(pathOrApi: string | Document, {
|
|
697
698
|
oasClass,
|
|
@@ -709,5 +710,5 @@ declare function merge(pathOrApi: Array<string | Document>, {
|
|
|
709
710
|
}): Promise<Oas>;
|
|
710
711
|
declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>;
|
|
711
712
|
//#endregion
|
|
712
|
-
export { DiscriminatorObject, Document, HttpMethod, HttpMethods, MediaTypeObject, Oas, type OasTypes, type OpenAPIV3, type OpenAPIV3_1, Operation, ReferenceObject, ResponseObject, SchemaObject, contentType, findSchemaDefinition, isDiscriminator, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, matchesMimeType, merge, parse, parseFromConfig };
|
|
713
|
+
export { DiscriminatorObject, Document, HttpMethod, HttpMethods, MediaTypeObject, Oas, type OasTypes, type OpenAPIV3, type OpenAPIV3_1, Operation, ReferenceObject, ResponseObject, SchemaObject, contentType, findSchemaDefinition, isAllOptional, isDiscriminator, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, matchesMimeType, merge, parse, parseFromConfig };
|
|
713
714
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -692,6 +692,7 @@ declare function isDiscriminator(obj?: any): obj is SchemaObject$1 & {
|
|
|
692
692
|
* @returns True if the schema is required; otherwise, false.
|
|
693
693
|
*/
|
|
694
694
|
declare function isRequired(schema?: SchemaObject$1): boolean;
|
|
695
|
+
declare function isAllOptional(schema: unknown): boolean;
|
|
695
696
|
declare function isOptional(schema?: SchemaObject$1): boolean;
|
|
696
697
|
declare function parse(pathOrApi: string | Document, {
|
|
697
698
|
oasClass,
|
|
@@ -709,5 +710,5 @@ declare function merge(pathOrApi: Array<string | Document>, {
|
|
|
709
710
|
}): Promise<Oas>;
|
|
710
711
|
declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>;
|
|
711
712
|
//#endregion
|
|
712
|
-
export { DiscriminatorObject, Document, HttpMethod, HttpMethods, MediaTypeObject, Oas, type OasTypes, type OpenAPIV3, type OpenAPIV3_1, Operation, ReferenceObject, ResponseObject, SchemaObject, contentType, findSchemaDefinition, isDiscriminator, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, matchesMimeType, merge, parse, parseFromConfig };
|
|
713
|
+
export { DiscriminatorObject, Document, HttpMethod, HttpMethods, MediaTypeObject, Oas, type OasTypes, type OpenAPIV3, type OpenAPIV3_1, Operation, ReferenceObject, ResponseObject, SchemaObject, contentType, findSchemaDefinition, isAllOptional, isDiscriminator, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, matchesMimeType, merge, parse, parseFromConfig };
|
|
713
714
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -4170,6 +4170,19 @@ function isRequired(schema) {
|
|
|
4170
4170
|
if (!schema) return false;
|
|
4171
4171
|
return Array.isArray(schema.required) ? !!schema.required?.length : !!schema.required;
|
|
4172
4172
|
}
|
|
4173
|
+
function isAllOptional(schema) {
|
|
4174
|
+
if (!schema) return true;
|
|
4175
|
+
if (isOptional(schema)) return true;
|
|
4176
|
+
const s = schema;
|
|
4177
|
+
if (Array.isArray(s?.required) && s?.required.length > 0) return false;
|
|
4178
|
+
const groups = [
|
|
4179
|
+
s?.allOf,
|
|
4180
|
+
s?.anyOf,
|
|
4181
|
+
s?.oneOf
|
|
4182
|
+
].filter((g) => Array.isArray(g));
|
|
4183
|
+
if (groups.length === 0) return true;
|
|
4184
|
+
return groups.every((arr) => arr.every((child) => isAllOptional(child)));
|
|
4185
|
+
}
|
|
4173
4186
|
function isOptional(schema) {
|
|
4174
4187
|
return !isRequired(schema);
|
|
4175
4188
|
}
|
|
@@ -4508,5 +4521,5 @@ const HttpMethods = {
|
|
|
4508
4521
|
};
|
|
4509
4522
|
|
|
4510
4523
|
//#endregion
|
|
4511
|
-
export { HttpMethods, Oas, findSchemaDefinition, isDiscriminator, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, matchesMimeType, merge, parse, parseFromConfig };
|
|
4524
|
+
export { HttpMethods, Oas, findSchemaDefinition, isAllOptional, isDiscriminator, isNullable, isOpenApiV3_1Document, isOptional, isParameterObject, isReference, isRequired, matchesMimeType, merge, parse, parseFromConfig };
|
|
4512
4525
|
//# sourceMappingURL=index.js.map
|