openapi-typescript-validator
Advanced tools
Comparing version 2.2.0 to 3.0.0-beta.0
@@ -1,2 +0,1 @@ | ||
import { FormatName } from "ajv-formats"; | ||
import { JSONSchema } from "json-schema-to-typescript"; | ||
@@ -11,14 +10,7 @@ declare type SchemaObject = JSONSchema; | ||
declare type PropertyValue = SchemaObject | CustomSchemaObject; | ||
export declare const boolean: SchemaObject; | ||
export declare const id: SchemaObject; | ||
export declare const positiveInteger: SchemaObject; | ||
export declare const string: SchemaObject; | ||
export declare const number: SchemaObject; | ||
export declare const any: SchemaObject; | ||
export declare const anonymousData: SchemaObject; | ||
interface StringFormat { | ||
type: "string"; | ||
format: FormatName; | ||
} | ||
interface FormatOptions { | ||
declare type PropertyBaseOptions = Pick<JSONSchema, "title" | "description" | "default">; | ||
declare type StringOptions = PropertyBaseOptions & Pick<JSONSchema, "minLength" | "maxLength" | "pattern">; | ||
declare type NumberOptions = PropertyBaseOptions & Pick<JSONSchema, "exclusiveMinimum" | "exclusiveMaximum" | "maximum" | "minimum" | "multipleOf">; | ||
declare type BooleanOptions = PropertyBaseOptions; | ||
interface FormatOptions extends StringOptions { | ||
formatMinimum?: string; | ||
@@ -29,17 +21,22 @@ formatMaximum?: string; | ||
} | ||
export declare const date: (options?: FormatOptions) => StringFormat; | ||
export declare const time: (options?: FormatOptions) => StringFormat; | ||
export declare const dateTime: (options?: FormatOptions) => StringFormat; | ||
export declare const duration: (options?: FormatOptions) => StringFormat; | ||
export declare const uri: (options?: FormatOptions) => StringFormat; | ||
export declare const uriReference: (options?: FormatOptions) => StringFormat; | ||
export declare const uriTemplate: (options?: FormatOptions) => StringFormat; | ||
export declare const email: (options?: FormatOptions) => StringFormat; | ||
export declare const hostname: (options?: FormatOptions) => StringFormat; | ||
export declare const ipv4: (options?: FormatOptions) => StringFormat; | ||
export declare const ipv6: (options?: FormatOptions) => StringFormat; | ||
export declare const regex: (options?: FormatOptions) => StringFormat; | ||
export declare const uuid: (options?: FormatOptions) => StringFormat; | ||
export declare const jsonPointer: (options?: FormatOptions) => StringFormat; | ||
export declare const relativeJsonPointer: (options?: FormatOptions) => StringFormat; | ||
export declare const string: (options?: StringOptions) => PropertyValue; | ||
export declare const number: (options?: NumberOptions) => PropertyValue; | ||
export declare const boolean: (options?: BooleanOptions) => PropertyValue; | ||
export declare const any: (options?: JSONSchema) => PropertyValue; | ||
export declare const anonymousData: (options: JSONSchema) => PropertyValue; | ||
export declare const date: (options?: FormatOptions) => PropertyValue; | ||
export declare const time: (options?: FormatOptions) => PropertyValue; | ||
export declare const dateTime: (options?: FormatOptions) => PropertyValue; | ||
export declare const duration: (options?: FormatOptions) => PropertyValue; | ||
export declare const uri: (options?: FormatOptions) => PropertyValue; | ||
export declare const uriReference: (options?: FormatOptions) => PropertyValue; | ||
export declare const uriTemplate: (options?: FormatOptions) => PropertyValue; | ||
export declare const email: (options?: FormatOptions) => PropertyValue; | ||
export declare const hostname: (options?: FormatOptions) => PropertyValue; | ||
export declare const ipv4: (options?: FormatOptions) => PropertyValue; | ||
export declare const ipv6: (options?: FormatOptions) => PropertyValue; | ||
export declare const regex: (options?: FormatOptions) => PropertyValue; | ||
export declare const uuid: (options?: FormatOptions) => PropertyValue; | ||
export declare const jsonPointer: (options?: FormatOptions) => PropertyValue; | ||
export declare const relativeJsonPointer: (options?: FormatOptions) => PropertyValue; | ||
export declare const object: (properties: Record<string, PropertyValue>) => SchemaObject; | ||
@@ -46,0 +43,0 @@ export declare const ref: (refName: string) => SchemaObject; |
@@ -14,12 +14,25 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.compose = exports.constant = exports.enumerate = exports.anyOf = exports.oneOf = exports.optional = exports.nillable = exports.nullable = exports.map = exports.array = exports.ref = exports.object = exports.relativeJsonPointer = exports.jsonPointer = exports.uuid = exports.regex = exports.ipv6 = exports.ipv4 = exports.hostname = exports.email = exports.uriTemplate = exports.uriReference = exports.uri = exports.duration = exports.dateTime = exports.time = exports.date = exports.anonymousData = exports.any = exports.number = exports.string = exports.positiveInteger = exports.id = exports.boolean = void 0; | ||
exports.boolean = { type: "boolean" }; | ||
exports.id = { type: "string", minLength: 1 }; | ||
exports.positiveInteger = { type: "integer", minimum: 0 }; | ||
exports.string = { type: "string" }; | ||
exports.number = { type: "number" }; | ||
exports.any = {}; | ||
exports.anonymousData = { | ||
additionalProperties: { type: "string" }, | ||
exports.compose = exports.constant = exports.enumerate = exports.anyOf = exports.oneOf = exports.optional = exports.nillable = exports.nullable = exports.map = exports.array = exports.ref = exports.object = exports.relativeJsonPointer = exports.jsonPointer = exports.uuid = exports.regex = exports.ipv6 = exports.ipv4 = exports.hostname = exports.email = exports.uriTemplate = exports.uriReference = exports.uri = exports.duration = exports.dateTime = exports.time = exports.date = exports.anonymousData = exports.any = exports.boolean = exports.number = exports.string = void 0; | ||
var string = function (options) { | ||
if (options === void 0) { options = {}; } | ||
return (__assign({ type: "string" }, options)); | ||
}; | ||
exports.string = string; | ||
var number = function (options) { | ||
if (options === void 0) { options = {}; } | ||
return (__assign({ type: "number" }, options)); | ||
}; | ||
exports.number = number; | ||
var boolean = function (options) { | ||
if (options === void 0) { options = {}; } | ||
return (__assign({ type: "boolean" }, options)); | ||
}; | ||
exports.boolean = boolean; | ||
var any = function (options) { | ||
if (options === void 0) { options = {}; } | ||
return (__assign({}, options)); | ||
}; | ||
exports.any = any; | ||
var anonymousData = function (options) { return (__assign({ additionalProperties: { type: "string" } }, options)); }; | ||
exports.anonymousData = anonymousData; | ||
var stringFormat = function (format) { return function (options) { | ||
@@ -26,0 +39,0 @@ if (options === void 0) { options = {}; } |
{ | ||
"name": "openapi-typescript-validator", | ||
"version": "2.2.0", | ||
"version": "3.0.0-beta.0", | ||
"description": "Generate typescript with ajv validation based on openapi schemas", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -154,3 +154,3 @@ # openapi-typescript-validator | ||
type: constant('title'), | ||
title: string, | ||
title: string(), | ||
subtitle: nillable(string), | ||
@@ -161,3 +161,3 @@ }); | ||
type: constant('image'), | ||
url: string, | ||
url: string(), | ||
}); | ||
@@ -214,2 +214,16 @@ | ||
## Breaking changes | ||
### upgrading to V3 | ||
When using the `custom` format for your schemas. The `string`, `boolean`, `number`, etc helpers are now a `function` instead of `const`. | ||
You'll need to update your schemas | ||
```javascript | ||
// v2 | ||
object({ title: string }) | ||
// v3: | ||
object({ title: string() }) | ||
``` | ||
## Documentation | ||
@@ -216,0 +230,0 @@ |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
66141
810
229
1