Merge pull request #68 from fearthecowboy/remodeler-work

Remodeler work
This commit is contained in:
Garrett Serack 2019-09-23 13:32:48 -07:00 коммит произвёл GitHub
Родитель 703c7c5f37 237fb6b2df
Коммит 22a666ac26
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
38 изменённых файлов: 16529 добавлений и 100 удалений

Просмотреть файл

@ -5,16 +5,41 @@
import { keys } from '@azure-tools/linq';
export type DeepPartial<T> = {
[P in keyof T]?:
T[P] extends Array<infer U> ? // if it is an array
Array<DeepPartial<U>> : // then use an Array of DeepPartial
T[P] extends ReadonlyArray<infer V> ? // if it's an ReadOnly Array,
ReadonlyArray<DeepPartial<V>> : // use a ReadOnly of DeepPartial
T[P] extends string | number | boolean | null | undefined ? // if it's a primitive
T[P] : // use that
DeepPartial<T[P]> // otherwise, it's a DeepPartial of the type.
};
export type Primitive = string | number | boolean | bigint | symbol | undefined | null;
export type XDeepPartial<T> = DeepPartial<T>;
export type DeepPartial<T> =
T extends Primitive | Function | Date ? T :
T extends Map<infer K, infer V> ? DeepPartialMap<K, V> :
T extends Set<infer U> ? DeepPartialSet<U> :
{
[P in keyof T]?:
T[P] extends Array<infer U> ? Array<DeepPartial<U>> :
T[P] extends ReadonlyArray<infer V> ? ReadonlyArray<DeepPartial<V>> :
T[P] extends Primitive ? T[P] :
DeepPartial<T[P]>
} | T;
export type NDeepPartial<T> =
T extends Primitive ? T :
T extends Function ? T :
T extends Date ? T :
T extends Map<infer K, infer V> ? DeepPartialMap<K, V> :
T extends Set<infer U> ? DeepPartialSet<U> :
T extends {} ? {
[P in keyof T]?:
// T[P] extends Array<infer U> ? Array<DeepPartial<U>> : // if it is an array then use an Array of DeepPartial
// T[P] extends ReadonlyArray<infer V> ? ReadonlyArray<DeepPartial<V>> : // if it's an ReadOnly Array, // use a ReadOnly of DeepPartial
T[P] extends string | number | boolean | null | undefined ? T[P] : // if it's a primitive use that
NDeepPartial<T[P]> // otherwise, it's a DeepPartial of the type.
} :
Partial<T>;
interface DeepPartialSet<ItemType> extends Set<NDeepPartial<ItemType>> { }
interface DeepPartialMap<KeyType, ValueType> extends Map<NDeepPartial<KeyType>, NDeepPartial<ValueType>> { }
function applyTo(source: any, target: any, cache = new Set<any>()) {
if (cache.has(source)) {

Просмотреть файл

@ -3,13 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { DEFAULT_SAFE_SCHEMA, dump, safeLoad } from 'js-yaml';
import { DEFAULT_SAFE_SCHEMA, dump, safeLoad, Schema } from 'js-yaml';
const propertyPriority = [
'$key',
'primitives',
'objects',
'dictionaries',
'compounds',
'choices',
'name',
'schemas',
'name',
'type',
'format',
'schema',
@ -71,24 +75,29 @@ function sortWithPriorty(a: any, b: any): number {
return ib != -1 || a > b ? 1 : a < b ? -1 : 0;
}
export function deserialize<T>(text: string, filename: string) {
export function deserialize<T>(text: string, filename: string, schema: Schema = DEFAULT_SAFE_SCHEMA) {
return <T>safeLoad(text, {
schema,
filename,
});
}
export function serialize<T>(model: T): string {
export function serialize<T>(model: T, schema: Schema = DEFAULT_SAFE_SCHEMA): string {
return dump(model, {
schema: schema,
sortKeys: sortWithPriorty,
schema: DEFAULT_SAFE_SCHEMA,
skipInvalid: true,
lineWidth: 240
}).
replace(/\s*\w*: {}/g, '').
replace(/\s*\w*: \[\]/g, '').
replace(/(\s*- \$key:)/g, '\n$1').
replace(/(\s*)(language:)/g, '\n$1## ----------------------------------------------------------------------$1$2')
// replace(/([^:]\n)(\s*-)/g, '$1\n$2')
;
lineWidth: 240,
})
.replace(/\s*\w*: {}/g, '')
.replace(/\s*\w*: \[\]/g, '')
.replace(/(\s*- \$key:)/g, '\n$1')
.replace(/-\n\s+version/g, '- version');
// .replace(/(\s*)(language:)/g, '\n$1## ----------------------------------------------------------------------$1$2')
// replace(/([^:]\n)(\s*-)/g, '$1\n$2')
//.replace(/(\s*language:)/g, '\n$1');
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,213 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"SchemaType": {
"description": "possible schema types that indicate the type of schema.",
"enum": [
"and",
"array",
"boolean",
"byte-array",
"char",
"choice",
"constant",
"credential",
"date",
"date-time",
"dictionary",
"duration",
"integer",
"not",
"number",
"object",
"odata-query",
"or",
"stream",
"string",
"unixtime",
"unknown",
"uri",
"uuid",
"xor"
],
"type": "string"
},
"SerializationStyle": {
"description": "The Serialization Style used for the parameter.\n\nDescribes how the parameter value will be serialized depending on the type of the parameter value.",
"enum": [
"deepObject",
"form",
"json",
"label",
"matrix",
"pipeDelimited",
"simple",
"spaceDelimited",
"xml"
],
"type": "string"
},
"QueryEncodingStyle": {
"enum": [
"deepObject",
"form",
"pipeDelimited",
"spaceDelimited"
],
"type": "string"
},
"PathEncodingStyle": {
"enum": [
"label",
"matrix",
"simple"
],
"type": "string"
},
"HttpMethod": {
"description": "standard HTTP protocol methods",
"enum": [
"delete",
"get",
"head",
"options",
"patch",
"post",
"put",
"trace"
],
"type": "string"
},
"ParameterLocation": {
"description": "the location that this parameter is placed in the http request",
"enum": [
"body",
"cookie",
"header",
"path",
"query"
],
"type": "string"
},
"Default": {
"description": "A catch-all for all un-handled response codes.",
"type": "string",
"enum": [
"default"
]
},
"StatusCode": {
"enum": [
100,
101,
102,
103,
200,
201,
202,
203,
204,
205,
206,
207,
208,
226,
300,
301,
302,
304,
305,
306,
307,
308,
400,
401,
402,
403,
404,
405,
406,
407,
408,
409,
410,
411,
412,
413,
414,
415,
416,
417,
418,
421,
422,
423,
424,
425,
426,
428,
429,
431,
451,
500,
501,
502,
503,
504,
505,
506,
507,
508,
510,
511,
"default"
]
},
"Scheme": {
"type": "string",
"enum": [
"bearer"
]
},
"SecurityType": {
"enum": [
"apiKey",
"http",
"oauth2",
"openIdConnect"
],
"type": "string"
},
"ImplementationLocation": {
"enum": [
"Client",
"Method"
],
"type": "string"
},
"NumericSchemaTypes": {
"enum": [
"integer",
"number"
],
"type": "string"
},
"PrimitiveSchemaTypes": {
"enum": [
"boolean",
"char",
"credential",
"date",
"date-time",
"duration",
"integer",
"number",
"string",
"unixtime",
"uri",
"uuid"
],
"type": "string"
}
}
}

Просмотреть файл

@ -0,0 +1,864 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"StreamResponse": {
"description": "a response where the content should be treated as a stream instead of a value or object",
"type": "object",
"properties": {
"stream": {
"description": "indicates that this response is a stream",
"type": "boolean",
"enum": [
true
]
},
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"language",
"protocol",
"stream"
]
},
"HttpServer": {
"description": "An object representing a Server.\n\nIf the uri supports template substitution, then the variables are required.",
"type": "object",
"properties": {
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"url": {
"description": "base url for the server",
"type": "string"
},
"variables": {
"description": "an optional collection of variables for server templating",
"type": "array",
"items": {
"$ref": "./http.json#/definitions/ServerVariable"
}
}
},
"defaultProperties": [],
"required": [
"language",
"url"
]
},
"ServerVariable": {
"description": "An object representing a Server Variable for server URL template substitution.",
"type": "object",
"properties": {
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"$key": {
"description": "common name of the aspect -- in OAI3 this was typically the key in the parent dictionary",
"type": "string"
},
"description": {
"description": "description of the aspect.",
"type": "string"
},
"apiVersions": {
"description": "API versions that this applies to. Undefined means all versions",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/ApiVersion"
}
},
"deprecated": {
"$ref": "./master.json#/definitions/Deprecation",
"description": "deprecation information -- ie, when this aspect doesn't apply and why"
},
"schema": {
"description": "the schema for the",
"anyOf": [
{
"$ref": "./schemas.json#/definitions/NumberSchema"
},
{
"$ref": "./schemas.json#/definitions/StringSchema"
},
{
"$ref": "./schemas.json#/definitions/ChoiceSchema"
}
]
},
"default": {
"description": "The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.",
"type": "string"
},
"required": {
"description": "if the value is marked 'required'.",
"type": "boolean"
}
},
"defaultProperties": [],
"required": [
"$key",
"description",
"language",
"schema"
]
},
"AuthorizationCodeOAuthFlow": {
"type": "object",
"properties": {
"authorizationUrl": {
"description": "an URI",
"type": "string"
},
"tokenUrl": {
"description": "an URI",
"type": "string"
},
"refreshUrl": {
"description": "an URI",
"type": "string"
},
"scopes": {
"$ref": "./master.json#/definitions/Dictionary<string>"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"authorizationUrl",
"scopes",
"tokenUrl"
]
},
"BearerHTTPSecurityScheme": {
"type": "object",
"properties": {
"scheme": {
"type": "string",
"enum": [
"bearer"
]
},
"bearerFormat": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"http"
]
},
"description": {
"type": "string"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"scheme",
"type"
]
},
"ClientCredentialsFlow": {
"type": "object",
"properties": {
"tokenUrl": {
"description": "an URI",
"type": "string"
},
"refreshUrl": {
"description": "an URI",
"type": "string"
},
"scopes": {
"$ref": "./master.json#/definitions/Dictionary<string>"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"scopes",
"tokenUrl"
]
},
"ImplicitOAuthFlow": {
"type": "object",
"properties": {
"authorizationUrl": {
"description": "an URI",
"type": "string"
},
"refreshUrl": {
"description": "an URI",
"type": "string"
},
"scopes": {
"$ref": "./master.json#/definitions/Dictionary<string>"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"authorizationUrl",
"scopes"
]
},
"NonBearerHTTPSecurityScheme": {
"type": "object",
"properties": {
"scheme": {
"type": "string"
},
"description": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"http"
]
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"scheme",
"type"
]
},
"OAuth2SecurityScheme": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"oauth2"
]
},
"flows": {
"$ref": "./http.json#/definitions/OAuthFlows"
},
"description": {
"type": "string"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"flows",
"type"
]
},
"OAuthFlows": {
"type": "object",
"properties": {
"implicit": {
"$ref": "./http.json#/definitions/ImplicitOAuthFlow"
},
"password": {
"$ref": "./http.json#/definitions/PasswordOAuthFlow"
},
"clientCredentials": {
"$ref": "./http.json#/definitions/ClientCredentialsFlow"
},
"authorizationCode": {
"$ref": "./http.json#/definitions/AuthorizationCodeOAuthFlow"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": []
},
"HTTPSecurityScheme": {
"anyOf": [
{
"$ref": "./http.json#/definitions/BearerHTTPSecurityScheme"
},
{
"$ref": "./http.json#/definitions/NonBearerHTTPSecurityScheme"
}
]
},
"SecurityScheme": {
"anyOf": [
{
"$ref": "./http.json#/definitions/BearerHTTPSecurityScheme"
},
{
"$ref": "./http.json#/definitions/NonBearerHTTPSecurityScheme"
},
{
"$ref": "./http.json#/definitions/OAuth2SecurityScheme"
},
{
"$ref": "./http.json#/definitions/APIKeySecurityScheme"
},
{
"$ref": "./http.json#/definitions/OpenIdConnectSecurityScheme"
}
]
},
"APIKeySecurityScheme": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"apiKey"
]
},
"name": {
"type": "string"
},
"in": {
"$ref": "./enums.json#/definitions/ParameterLocation"
},
"description": {
"type": "string"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"in",
"name",
"type"
]
},
"OpenIdConnectSecurityScheme": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"openIdConnect"
]
},
"openIdConnectUrl": {
"description": "an URI",
"type": "string"
},
"description": {
"type": "string"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"openIdConnectUrl",
"type"
]
},
"PasswordOAuthFlow": {
"type": "object",
"properties": {
"tokenUrl": {
"description": "an URI",
"type": "string"
},
"refreshUrl": {
"description": "an URI",
"type": "string"
},
"scopes": {
"$ref": "./master.json#/definitions/Dictionary<string>"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"scopes",
"tokenUrl"
]
},
"SecurityRequirement": {
"description": "common ways of serializing simple parameters",
"type": "object",
"defaultProperties": []
},
"HttpParameter": {
"description": "extended metadata for HTTP operation parameters",
"type": "object",
"properties": {
"in": {
"$ref": "./enums.json#/definitions/ParameterLocation",
"description": "the location that this parameter is placed in the http request"
},
"style": {
"$ref": "./enums.json#/definitions/SerializationStyle",
"description": "the Serialization Style used for the parameter."
},
"skipUriEncoding": {
"description": "when set, this indicates that the content of the parameter should not be subject to URI encoding rules.",
"type": "boolean"
},
"implementation": {
"$ref": "./enums.json#/definitions/ImplementationLocation",
"description": "suggested implementation location for this parameter"
}
},
"defaultProperties": [],
"required": [
"implementation",
"in",
"style"
]
},
"HttpRequest": {
"description": "HTTP operation protocol data",
"type": "object",
"properties": {
"path": {
"description": "A relative path to an individual endpoint. \n\nThe field name MUST begin with a slash. \nThe path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL. \nPath templating is allowed. \n\nWhen matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.",
"type": "string"
},
"method": {
"$ref": "./enums.json#/definitions/HttpMethod",
"description": "the HTTP Method used to process this operation"
},
"servers": {
"description": "each method must have one or more servers that it is connected to.",
"type": "array",
"items": {
"$ref": "./http.json#/definitions/HttpServer"
}
}
},
"defaultProperties": [],
"required": [
"method",
"path",
"servers"
]
},
"HttpWithBodyRequest": {
"type": "object",
"properties": {
"mediaType": {
"description": "must set a media type for the body",
"type": "string"
},
"path": {
"description": "A relative path to an individual endpoint. \n\nThe field name MUST begin with a slash. \nThe path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL. \nPath templating is allowed. \n\nWhen matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.",
"type": "string"
},
"method": {
"$ref": "./enums.json#/definitions/HttpMethod",
"description": "the HTTP Method used to process this operation"
},
"servers": {
"description": "each method must have one or more servers that it is connected to.",
"type": "array",
"items": {
"$ref": "./http.json#/definitions/HttpServer"
}
}
},
"defaultProperties": [],
"required": [
"mediaType",
"method",
"path",
"servers"
]
},
"HttpStreamRequest": {
"type": "object",
"properties": {
"stream": {
"type": "boolean",
"enum": [
true
]
},
"mediaType": {
"description": "must set a media type for the body",
"type": "string"
},
"path": {
"description": "A relative path to an individual endpoint. \n\nThe field name MUST begin with a slash. \nThe path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL. \nPath templating is allowed. \n\nWhen matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.",
"type": "string"
},
"method": {
"$ref": "./enums.json#/definitions/HttpMethod",
"description": "the HTTP Method used to process this operation"
},
"servers": {
"description": "each method must have one or more servers that it is connected to.",
"type": "array",
"items": {
"$ref": "./http.json#/definitions/HttpServer"
}
}
},
"defaultProperties": [],
"required": [
"mediaType",
"method",
"path",
"servers",
"stream"
]
},
"HttpMultiPartRequest": {
"type": "object",
"properties": {
"multipart": {
"description": "indicates that the HTTP Request should be a multipart request \n\nie, that it has multiple requests in a single request.",
"type": "boolean",
"enum": [
true
]
},
"parts": {
"description": "the multiple request parts that make up this request ?? is this right?",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/Request"
}
},
"mediaType": {
"description": "must set a media type for the body",
"type": "string"
},
"path": {
"description": "A relative path to an individual endpoint. \n\nThe field name MUST begin with a slash. \nThe path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL. \nPath templating is allowed. \n\nWhen matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.",
"type": "string"
},
"method": {
"$ref": "./enums.json#/definitions/HttpMethod",
"description": "the HTTP Method used to process this operation"
},
"servers": {
"description": "each method must have one or more servers that it is connected to.",
"type": "array",
"items": {
"$ref": "./http.json#/definitions/HttpServer"
}
}
},
"defaultProperties": [],
"required": [
"mediaType",
"method",
"multipart",
"parts",
"path",
"servers"
]
},
"HttpMultipartRequest": {
"type": "object",
"properties": {
"multipart": {
"description": "indicates that the HTTP Request should be a multipart request \n\nie, that it has multiple requests in a single request.",
"type": "boolean",
"enum": [
true
],
"default": true
},
"parts": {
"description": "the multiple request parts that make up this request ?? is this right?",
"type": "array",
"items": {},
"default": []
},
"mediaType": {
"description": "must set a media type for the body",
"type": "string"
},
"path": {
"description": "A relative path to an individual endpoint. \n\nThe field name MUST begin with a slash. \nThe path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL. \nPath templating is allowed. \n\nWhen matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.",
"type": "string"
},
"method": {
"$ref": "./enums.json#/definitions/HttpMethod",
"description": "the HTTP Method used to process this operation"
},
"servers": {
"description": "each method must have one or more servers that it is connected to.",
"type": "array",
"items": {
"$ref": "./http.json#/definitions/HttpServer"
}
}
},
"defaultProperties": [],
"required": [
"mediaType",
"method",
"multipart",
"parts",
"path",
"servers"
]
},
"HttpResponse": {
"type": "object",
"properties": {
"statusCodes": {
"description": "the possible HTTP status codes that this response MUST match one of.",
"type": "array",
"items": {
"enum": [
100,
101,
102,
103,
200,
201,
202,
203,
204,
205,
206,
207,
208,
226,
300,
301,
302,
304,
305,
306,
307,
308,
400,
401,
402,
403,
404,
405,
406,
407,
408,
409,
410,
411,
412,
413,
414,
415,
416,
417,
418,
421,
422,
423,
424,
425,
426,
428,
429,
431,
451,
500,
501,
502,
503,
504,
505,
506,
507,
508,
510,
511,
"default"
]
}
},
"mediaTypes": {
"description": "the possible media types that this response MUST match one of",
"type": "array",
"items": {
"type": "string"
}
},
"headers": {
"description": "content returned by the service in the HTTP headers",
"type": "array",
"items": {
"$ref": "./schemas.json#/definitions/Schema"
}
}
},
"defaultProperties": [],
"required": [
"headers",
"mediaTypes",
"statusCodes"
]
},
"HttpStreamResponse": {
"type": "object",
"properties": {
"stream": {
"description": "stream responses",
"type": "boolean",
"enum": [
true
]
},
"statusCodes": {
"description": "the possible HTTP status codes that this response MUST match one of.",
"type": "array",
"items": {
"enum": [
100,
101,
102,
103,
200,
201,
202,
203,
204,
205,
206,
207,
208,
226,
300,
301,
302,
304,
305,
306,
307,
308,
400,
401,
402,
403,
404,
405,
406,
407,
408,
409,
410,
411,
412,
413,
414,
415,
416,
417,
418,
421,
422,
423,
424,
425,
426,
428,
429,
431,
451,
500,
501,
502,
503,
504,
505,
506,
507,
508,
510,
511,
"default"
]
}
},
"mediaTypes": {
"description": "the possible media types that this response MUST match one of",
"type": "array",
"items": {
"type": "string"
}
},
"headers": {
"description": "content returned by the service in the HTTP headers",
"type": "array",
"items": {
"$ref": "./schemas.json#/definitions/Schema"
}
}
},
"defaultProperties": [],
"required": [
"headers",
"mediaTypes",
"statusCodes",
"stream"
]
},
"HttpModel": {
"description": "code model metadata for HTTP protocol",
"type": "object",
"properties": {
"servers": {
"description": "a collection of server definitions for the service",
"type": "array",
"items": {
"$ref": "./http.json#/definitions/HttpServer"
}
},
"security": {
"description": "a collection of security requirements for the service",
"type": "array",
"items": {
"$ref": "./http.json#/definitions/SecurityRequirement"
}
}
},
"defaultProperties": [],
"required": [
"servers"
]
}
}
}

Просмотреть файл

@ -0,0 +1,924 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ApiVersion": {
"description": "- since API version formats range from \nAzure ARM API date style (2018-01-01) to semver (1.2.3) \nand virtually any other text, this value tends to be an \nopaque string with the possibility of a modifier to indicate\nthat it is a range.\n\noptions: \n- prepend a dash or append a plus to indicate a range \n(ie, '2018-01-01+' or '-2019-01-01', or '1.0+' )\n\n- semver-range style (ie, '^1.0.0' or '~1.0.0' )",
"type": "object",
"properties": {
"version": {
"description": "the actual api version string used in the API",
"type": "string"
},
"range": {
"enum": [
"+",
"-"
],
"type": "string"
}
},
"defaultProperties": [],
"required": [
"version"
]
},
"ApiVersions": {
"description": "a collection of api versions",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/ApiVersion"
}
},
"Deprecation": {
"description": "represents deprecation information for a given aspect",
"type": "object",
"properties": {
"message": {
"description": "the reason why this aspect",
"type": "string"
},
"apiVersions": {
"description": "the api versions that this deprecation is applicable to.",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/ApiVersion"
}
}
},
"defaultProperties": [],
"required": [
"apiVersions",
"message"
]
},
"Extensions": {
"type": "object",
"properties": {
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": []
},
"uri": {
"description": "an URI",
"type": "string"
},
"ExternalDocumentation": {
"description": "a reference to external documentation",
"type": "object",
"properties": {
"description": {
"type": "string"
},
"url": {
"description": "an URI",
"type": "string"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"url"
]
},
"Languages": {
"description": "custom extensible metadata for individual language generators",
"type": "object",
"additionalProperties": {},
"properties": {
"default": {
"$ref": "./master.json#/definitions/Language"
},
"csharp": {
"$ref": "./master.json#/definitions/Language"
},
"python": {
"$ref": "./master.json#/definitions/Language"
},
"ruby": {
"$ref": "./master.json#/definitions/Language"
},
"go": {
"$ref": "./master.json#/definitions/Language"
},
"typescript": {
"$ref": "./master.json#/definitions/Language"
},
"javascript": {
"$ref": "./master.json#/definitions/Language"
},
"powershell": {
"$ref": "./master.json#/definitions/Language"
},
"java": {
"$ref": "./master.json#/definitions/Language"
},
"c": {
"$ref": "./master.json#/definitions/Language"
},
"cpp": {
"$ref": "./master.json#/definitions/Language"
},
"swift": {
"$ref": "./master.json#/definitions/Language"
},
"objectivec": {
"$ref": "./master.json#/definitions/Language"
}
},
"defaultProperties": [],
"required": [
"default"
]
},
"Protocols": {
"description": "custom extensible metadata for individual protocols (ie, HTTP, etc)",
"type": "object",
"additionalProperties": {},
"properties": {
"http": {
"$ref": "./master.json#/definitions/Protocol"
},
"amqp": {
"$ref": "./master.json#/definitions/Protocol"
},
"mqtt": {
"$ref": "./master.json#/definitions/Protocol"
},
"jsonrpc": {
"$ref": "./master.json#/definitions/Protocol"
}
},
"defaultProperties": []
},
"Metadata": {
"description": "common pattern for Metadata on aspects",
"type": "object",
"properties": {
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"language",
"protocol"
]
},
"Language": {
"type": "object",
"properties": {
"name": {
"description": "name used in actual implementation",
"type": "string"
},
"description": {
"description": "description text - describes this node.",
"type": "string"
}
},
"defaultProperties": [],
"required": [
"description",
"name"
]
},
"Protocol": {
"type": "object",
"defaultProperties": []
},
"XmlSerlializationFormat": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"prefix": {
"type": "string"
},
"attribute": {
"type": "boolean"
},
"wrapped": {
"type": "boolean"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"attribute",
"wrapped"
]
},
"SerializationFormats": {
"description": "custom extensible metadata for individual serialization formats",
"type": "object",
"additionalProperties": {},
"properties": {
"json": {
"$ref": "./master.json#/definitions/Extensions"
},
"xml": {
"$ref": "./master.json#/definitions/XmlSerlializationFormat"
},
"protobuf": {
"$ref": "./master.json#/definitions/Extensions"
}
},
"defaultProperties": []
},
"Discriminator": {
"description": "Disciminator for polymorphic class hierarchy",
"type": "object",
"properties": {
"propertyName": {
"type": "string"
},
"mapping": {
"$ref": "./master.json#/definitions/Dictionary<string>"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"propertyName"
]
},
"Value": {
"description": "common base interface for properties, parameters and the like.",
"type": "object",
"properties": {
"schema": {
"$ref": "./schemas.json#/definitions/Schema",
"description": "the schema of this Value"
},
"required": {
"description": "if the value is marked 'required'.",
"type": "boolean"
},
"nullable": {
"description": "can null be passed in instead",
"type": "boolean"
},
"$key": {
"type": "string"
},
"description": {
"type": "string"
},
"uid": {
"type": "string"
},
"summary": {
"description": "a short description",
"type": "string"
},
"apiVersions": {
"description": "API versions that this applies to. Undefined means all versions",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/ApiVersion"
}
},
"deprecated": {
"$ref": "./master.json#/definitions/Deprecation",
"description": "deprecation information -- ie, when this aspect doesn't apply and why"
},
"externalDocs": {
"$ref": "./master.json#/definitions/ExternalDocumentation",
"description": "External Documentation Links"
},
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"$key",
"description",
"language",
"protocol",
"schema",
"uid"
]
},
"Property": {
"description": "a property is a child value in an object",
"type": "object",
"properties": {
"readOnly": {
"description": "if the property is marked read-only (ie, not intended to be sent to the service)",
"type": "boolean"
},
"serializedName": {
"description": "the wire name of this property",
"type": "string"
},
"schema": {
"$ref": "./schemas.json#/definitions/Schema",
"description": "the schema of this Value"
},
"required": {
"description": "if the value is marked 'required'.",
"type": "boolean"
},
"nullable": {
"description": "can null be passed in instead",
"type": "boolean"
},
"$key": {
"type": "string"
},
"description": {
"type": "string"
},
"uid": {
"type": "string"
},
"summary": {
"description": "a short description",
"type": "string"
},
"apiVersions": {
"description": "API versions that this applies to. Undefined means all versions",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/ApiVersion"
}
},
"deprecated": {
"$ref": "./master.json#/definitions/Deprecation",
"description": "deprecation information -- ie, when this aspect doesn't apply and why"
},
"externalDocs": {
"$ref": "./master.json#/definitions/ExternalDocumentation",
"description": "External Documentation Links"
},
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"$key",
"description",
"language",
"protocol",
"schema",
"serializedName",
"uid"
]
},
"SchemaMetadata": {
"description": "language metadata specific to schema instances",
"type": "object",
"properties": {
"namespace": {
"description": "namespace of the implementation of this item",
"type": "string"
},
"discriminatorValue": {
"description": "if this is a child of a polymorphic class, this will have the value of the descriminator.",
"type": "string"
},
"name": {
"description": "name used in actual implementation",
"type": "string"
},
"description": {
"description": "description text - describes this node.",
"type": "string"
}
},
"defaultProperties": [],
"required": [
"description",
"name"
]
},
"SerializationFormat": {
"type": "object",
"properties": {
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": []
},
"email": {
"type": "string"
},
"Contact": {
"description": "contact information",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"url": {
"description": "an URI",
"type": "string"
},
"email": {
"type": "string"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": []
},
"License": {
"description": "license information",
"type": "object",
"properties": {
"name": {
"description": "the nameof the license",
"type": "string"
},
"url": {
"description": "an uri pointing to the full license text",
"type": "string"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"name"
]
},
"Info": {
"description": "code model information",
"type": "object",
"properties": {
"title": {
"description": "the title of this service.",
"type": "string"
},
"description": {
"description": "a text description of the service",
"type": "string"
},
"termsOfService": {
"description": "an uri to the terms of service specified to access the service",
"type": "string"
},
"contact": {
"$ref": "./master.json#/definitions/Contact",
"description": "contact information for the service"
},
"license": {
"$ref": "./master.json#/definitions/License",
"description": "license information for th service"
},
"externalDocs": {
"$ref": "./master.json#/definitions/ExternalDocumentation",
"description": "External Documentation"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"title"
]
},
"Parameter": {
"description": "a definition of an discrete input for an operation",
"type": "object",
"properties": {
"schema": {
"$ref": "./schemas.json#/definitions/Schema",
"description": "the schema of this Value"
},
"required": {
"description": "if the value is marked 'required'.",
"type": "boolean"
},
"nullable": {
"description": "can null be passed in instead",
"type": "boolean"
},
"$key": {
"type": "string"
},
"description": {
"type": "string"
},
"uid": {
"type": "string"
},
"summary": {
"description": "a short description",
"type": "string"
},
"apiVersions": {
"description": "API versions that this applies to. Undefined means all versions",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/ApiVersion"
}
},
"deprecated": {
"$ref": "./master.json#/definitions/Deprecation",
"description": "deprecation information -- ie, when this aspect doesn't apply and why"
},
"externalDocs": {
"$ref": "./master.json#/definitions/ExternalDocumentation",
"description": "External Documentation Links"
},
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"$key",
"description",
"language",
"protocol",
"schema",
"uid"
]
},
"Response": {
"description": "a response from a service.",
"type": "object",
"properties": {
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"language",
"protocol"
]
},
"SchemaResponse": {
"description": "a response that should be deserialized into a result of type(schema)",
"type": "object",
"properties": {
"schema": {
"$ref": "./schemas.json#/definitions/Schema",
"description": "the content returned by the service for a given operaiton"
},
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"language",
"protocol",
"schema"
]
},
"Operation": {
"description": "represents a single callable endpoint with a discrete set of inputs, and any number of output possibilities (responses or exceptions)",
"type": "object",
"properties": {
"request": {
"$ref": "./master.json#/definitions/Request",
"description": "the inputs that are used to build the request."
},
"responses": {
"description": "responses that indicate a successful call",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/Response"
}
},
"exceptions": {
"description": "responses that indicate a failed call",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/Response"
}
},
"profile": {
"$ref": "./master.json#/definitions/Dictionary<ApiVersion>",
"description": "the apiVersion to use for a given profile name"
},
"$key": {
"type": "string"
},
"description": {
"type": "string"
},
"uid": {
"type": "string"
},
"summary": {
"description": "a short description",
"type": "string"
},
"apiVersions": {
"description": "API versions that this applies to. Undefined means all versions",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/ApiVersion"
}
},
"deprecated": {
"$ref": "./master.json#/definitions/Deprecation",
"description": "deprecation information -- ie, when this aspect doesn't apply and why"
},
"externalDocs": {
"$ref": "./master.json#/definitions/ExternalDocumentation",
"description": "External Documentation Links"
},
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"$key",
"description",
"exceptions",
"language",
"profile",
"protocol",
"request",
"responses",
"uid"
]
},
"Request": {
"type": "object",
"properties": {
"parameters": {
"description": "the parameter inputs to the operation",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/Parameter"
}
},
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"language",
"protocol"
]
},
"OperationGroup": {
"description": "an operation group represents a container around set of operations",
"type": "object",
"properties": {
"$key": {
"type": "string"
},
"operations": {
"type": "array",
"items": {
"$ref": "./master.json#/definitions/Operation"
}
},
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"$key",
"language",
"operations",
"protocol"
]
},
"CodeModel": {
"description": "the model that contains all the information required to generate a service api",
"type": "object",
"properties": {
"info": {
"$ref": "./master.json#/definitions/Info",
"description": "Code model information"
},
"schemas": {
"$ref": "./schemas.json#/definitions/Schemas",
"description": "All schemas for the model"
},
"operationGroups": {
"description": "All operations",
"type": "array",
"items": {
"$ref": "./master.json#/definitions/OperationGroup"
}
},
"language": {
"$ref": "./master.json#/definitions/Languages",
"description": "per-language information for this aspect"
},
"protocol": {
"$ref": "./master.json#/definitions/Protocols",
"description": "per-protocol information for this aspect"
},
"extensions": {
"$ref": "./master.json#/definitions/Dictionary<any>",
"description": "additional metadata extensions dictionary"
}
},
"defaultProperties": [],
"required": [
"info",
"language",
"operationGroups",
"protocol",
"schemas"
]
},
"Example": {
"description": "example data [UNFINISHED]",
"type": "object",
"properties": {
"summary": {
"type": "string"
},
"description": {
"type": "string"
},
"value": {},
"externalValue": {
"description": "an URI",
"type": "string"
}
},
"defaultProperties": []
},
"Dictionary<any>": {
"type": "object",
"additionalProperties": true,
"defaultProperties": []
},
"Dictionary<string>": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"defaultProperties": []
},
"Languages<SchemaMetadata>": {
"description": "custom extensible metadata for individual language generators",
"type": "object",
"additionalProperties": {},
"properties": {
"default": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"csharp": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"python": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"ruby": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"go": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"typescript": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"javascript": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"powershell": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"java": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"c": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"cpp": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"swift": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
},
"objectivec": {
"$ref": "./schemas.json#/definitions/SchemaMetadata"
}
},
"defaultProperties": [],
"required": [
"default"
]
},
"Dictionary<ApiVersion>": {
"type": "object",
"additionalProperties": {
"$ref": "./master.json#/definitions/ApiVersion"
},
"defaultProperties": []
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,213 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"CompoundSchemas": {
"anyOf": [
{
"$ref": "./schemas.json#/definitions/AndSchema"
},
{
"$ref": "./schemas.json#/definitions/OrSchema"
},
{
"$ref": "./schemas.json#/definitions/XorSchema"
}
]
},
"PrimitiveSchemas": {
"anyOf": [
{
"$ref": "./schemas.json#/definitions/NumberSchema"
},
{
"$ref": "./schemas.json#/definitions/StringSchema"
},
{
"$ref": "./schemas.json#/definitions/BooleanSchema"
},
{
"$ref": "./schemas.json#/definitions/CredentialSchema"
},
{
"$ref": "./schemas.json#/definitions/UriSchema"
},
{
"$ref": "./schemas.json#/definitions/UuidSchema"
},
{
"$ref": "./schemas.json#/definitions/DurationSchema"
},
{
"$ref": "./schemas.json#/definitions/DateTimeSchema"
},
{
"$ref": "./schemas.json#/definitions/DateSchema"
},
{
"$ref": "./schemas.json#/definitions/CharSchema"
},
{
"$ref": "./schemas.json#/definitions/UnixTimeSchema"
}
]
},
"ObjectSchemas": {
"anyOf": [
{
"$ref": "./schemas.json#/definitions/ObjectSchema"
},
{
"$ref": "./schemas.json#/definitions/AndSchema"
},
{
"$ref": "./schemas.json#/definitions/OrSchema"
},
{
"$ref": "./schemas.json#/definitions/DictionarySchema"
}
]
},
"AllSchemas": {
"anyOf": [
{
"$ref": "./schemas.json#/definitions/NumberSchema"
},
{
"$ref": "./schemas.json#/definitions/StringSchema"
},
{
"$ref": "./schemas.json#/definitions/ObjectSchema"
},
{
"$ref": "./schemas.json#/definitions/BooleanSchema"
},
{
"$ref": "./schemas.json#/definitions/CredentialSchema"
},
{
"$ref": "./schemas.json#/definitions/UriSchema"
},
{
"$ref": "./schemas.json#/definitions/UuidSchema"
},
{
"$ref": "./schemas.json#/definitions/DurationSchema"
},
{
"$ref": "./schemas.json#/definitions/DateTimeSchema"
},
{
"$ref": "./schemas.json#/definitions/DateSchema"
},
{
"$ref": "./schemas.json#/definitions/CharSchema"
},
{
"$ref": "./schemas.json#/definitions/ByteArraySchema"
},
{
"$ref": "./schemas.json#/definitions/UnixTimeSchema"
},
{
"$ref": "./schemas.json#/definitions/AndSchema"
},
{
"$ref": "./schemas.json#/definitions/OrSchema"
},
{
"$ref": "./schemas.json#/definitions/ArraySchema"
},
{
"$ref": "./schemas.json#/definitions/ChoiceSchema"
},
{
"$ref": "./schemas.json#/definitions/DictionarySchema"
},
{
"$ref": "./schemas.json#/definitions/ConstantSchema"
}
]
},
"CompoundSchemaTypes": {
"enum": [
"and",
"or",
"xor"
],
"type": "string"
},
"PrimitiveSchemaTypes": {
"enum": [
"boolean",
"char",
"credential",
"date",
"date-time",
"duration",
"integer",
"number",
"string",
"unixtime",
"uri",
"uuid"
],
"type": "string"
},
"ValueSchemaTypes": {
"enum": [
"array",
"boolean",
"byte-array",
"char",
"choice",
"credential",
"date",
"date-time",
"duration",
"integer",
"number",
"string",
"unixtime",
"uri",
"uuid"
],
"type": "string"
},
"ObjectSchemaTypes": {
"enum": [
"and",
"dictionary",
"object",
"or"
],
"type": "string"
},
"AllSchemaTypes": {
"enum": [
"and",
"array",
"boolean",
"byte-array",
"char",
"choice",
"constant",
"credential",
"date",
"date-time",
"dictionary",
"duration",
"integer",
"number",
"object",
"odata-query",
"or",
"string",
"unixtime",
"uri",
"uuid",
"xor"
],
"type": "string"
}
}
}

Просмотреть файл

@ -0,0 +1,187 @@
$schema: 'http://json-schema.org/draft-07/schema#'
definitions:
Default:
type: string
description: A catch-all for all un-handled response codes.
enum:
- default
HttpMethod:
type: string
description: standard HTTP protocol methods
enum:
- delete
- get
- head
- options
- patch
- post
- put
- trace
ImplementationLocation:
type: string
enum:
- Client
- Method
NumericSchemaTypes:
type: string
enum:
- integer
- number
ParameterLocation:
type: string
description: the location that this parameter is placed in the http request
enum:
- body
- cookie
- header
- path
- query
PathEncodingStyle:
type: string
enum:
- label
- matrix
- simple
PrimitiveSchemaTypes:
type: string
enum:
- boolean
- char
- credential
- date
- date-time
- duration
- integer
- number
- string
- unixtime
- uri
- uuid
QueryEncodingStyle:
type: string
enum:
- deepObject
- form
- pipeDelimited
- spaceDelimited
SchemaType:
type: string
description: possible schema types that indicate the type of schema.
enum:
- and
- array
- boolean
- byte-array
- char
- choice
- constant
- credential
- date
- date-time
- dictionary
- duration
- integer
- not
- number
- object
- odata-query
- or
- stream
- string
- unixtime
- unknown
- uri
- uuid
- xor
Scheme:
type: string
enum:
- bearer
SecurityType:
type: string
enum:
- apiKey
- http
- oauth2
- openIdConnect
SerializationStyle:
type: string
description: |-
The Serialization Style used for the parameter.
Describes how the parameter value will be serialized depending on the type of the parameter value.
enum:
- deepObject
- form
- json
- label
- matrix
- pipeDelimited
- simple
- spaceDelimited
- xml
StatusCode:
enum:
- 100
- 101
- 102
- 103
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 226
- 300
- 301
- 302
- 304
- 305
- 306
- 307
- 308
- 400
- 401
- 402
- 403
- 404
- 405
- 406
- 407
- 408
- 409
- 410
- 411
- 412
- 413
- 414
- 415
- 416
- 417
- 418
- 421
- 422
- 423
- 424
- 425
- 426
- 428
- 429
- 431
- 451
- 500
- 501
- 502
- 503
- 504
- 505
- 506
- 507
- 508
- 510
- 511
- default

Просмотреть файл

@ -0,0 +1,664 @@
$schema: 'http://json-schema.org/draft-07/schema#'
definitions:
APIKeySecurityScheme:
type: object
properties:
name:
type: string
type:
type: string
enum:
- apiKey
description:
type: string
in:
$ref: './enums.yaml#/definitions/ParameterLocation'
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- in
- name
- type
AuthorizationCodeOAuthFlow:
type: object
properties:
authorizationUrl:
type: string
description: an URI
refreshUrl:
type: string
description: an URI
scopes:
$ref: './master.yaml#/definitions/Dictionary<string>'
tokenUrl:
type: string
description: an URI
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- authorizationUrl
- scopes
- tokenUrl
BearerHTTPSecurityScheme:
type: object
properties:
type:
type: string
enum:
- http
description:
type: string
bearerFormat:
type: string
scheme:
type: string
enum:
- bearer
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- scheme
- type
ClientCredentialsFlow:
type: object
properties:
refreshUrl:
type: string
description: an URI
scopes:
$ref: './master.yaml#/definitions/Dictionary<string>'
tokenUrl:
type: string
description: an URI
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- scopes
- tokenUrl
HTTPSecurityScheme:
anyOf:
- $ref: './http.yaml#/definitions/BearerHTTPSecurityScheme'
- $ref: './http.yaml#/definitions/NonBearerHTTPSecurityScheme'
HttpModel:
type: object
description: code model metadata for HTTP protocol
properties:
security:
type: array
description: a collection of security requirements for the service
items:
$ref: './http.yaml#/definitions/SecurityRequirement'
servers:
type: array
description: a collection of server definitions for the service
items:
$ref: './http.yaml#/definitions/HttpServer'
required:
- servers
HttpMultiPartRequest:
type: object
properties:
path:
type: string
description: |-
A relative path to an individual endpoint.
The field name MUST begin with a slash.
The path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL.
Path templating is allowed.
When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
method:
description: the HTTP Method used to process this operation
$ref: './enums.yaml#/definitions/HttpMethod'
mediaType:
type: string
description: must set a media type for the body
multipart:
type: boolean
description: |-
indicates that the HTTP Request should be a multipart request
ie, that it has multiple requests in a single request.
enum:
- true
parts:
type: array
description: the multiple request parts that make up this request ?? is this right?
items:
$ref: './master.yaml#/definitions/Request'
servers:
type: array
description: each method must have one or more servers that it is connected to.
items:
$ref: './http.yaml#/definitions/HttpServer'
required:
- mediaType
- method
- multipart
- parts
- path
- servers
HttpMultipartRequest:
type: object
properties:
path:
type: string
description: |-
A relative path to an individual endpoint.
The field name MUST begin with a slash.
The path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL.
Path templating is allowed.
When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
method:
description: the HTTP Method used to process this operation
$ref: './enums.yaml#/definitions/HttpMethod'
mediaType:
type: string
description: must set a media type for the body
multipart:
type: boolean
description: |-
indicates that the HTTP Request should be a multipart request
ie, that it has multiple requests in a single request.
default: true
enum:
- true
parts:
type: array
description: the multiple request parts that make up this request ?? is this right?
servers:
type: array
description: each method must have one or more servers that it is connected to.
items:
$ref: './http.yaml#/definitions/HttpServer'
required:
- mediaType
- method
- multipart
- parts
- path
- servers
HttpParameter:
type: object
description: extended metadata for HTTP operation parameters
properties:
implementation:
description: suggested implementation location for this parameter
$ref: './enums.yaml#/definitions/ImplementationLocation'
in:
description: the location that this parameter is placed in the http request
$ref: './enums.yaml#/definitions/ParameterLocation'
skipUriEncoding:
type: boolean
description: 'when set, this indicates that the content of the parameter should not be subject to URI encoding rules.'
style:
description: the Serialization Style used for the parameter.
$ref: './enums.yaml#/definitions/SerializationStyle'
required:
- implementation
- in
- style
HttpRequest:
type: object
description: HTTP operation protocol data
properties:
path:
type: string
description: |-
A relative path to an individual endpoint.
The field name MUST begin with a slash.
The path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL.
Path templating is allowed.
When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
method:
description: the HTTP Method used to process this operation
$ref: './enums.yaml#/definitions/HttpMethod'
servers:
type: array
description: each method must have one or more servers that it is connected to.
items:
$ref: './http.yaml#/definitions/HttpServer'
required:
- method
- path
- servers
HttpResponse:
type: object
properties:
headers:
type: array
description: content returned by the service in the HTTP headers
items:
$ref: './schemas.yaml#/definitions/Schema'
mediaTypes:
type: array
description: the possible media types that this response MUST match one of
items:
type: string
statusCodes:
type: array
description: the possible HTTP status codes that this response MUST match one of.
items:
enum:
- 100
- 101
- 102
- 103
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 226
- 300
- 301
- 302
- 304
- 305
- 306
- 307
- 308
- 400
- 401
- 402
- 403
- 404
- 405
- 406
- 407
- 408
- 409
- 410
- 411
- 412
- 413
- 414
- 415
- 416
- 417
- 418
- 421
- 422
- 423
- 424
- 425
- 426
- 428
- 429
- 431
- 451
- 500
- 501
- 502
- 503
- 504
- 505
- 506
- 507
- 508
- 510
- 511
- default
required:
- headers
- mediaTypes
- statusCodes
HttpServer:
type: object
description: |-
An object representing a Server.
If the uri supports template substitution, then the variables are required.
properties:
url:
type: string
description: base url for the server
variables:
type: array
description: an optional collection of variables for server templating
items:
$ref: './http.yaml#/definitions/ServerVariable'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
required:
- language
- url
HttpStreamRequest:
type: object
properties:
path:
type: string
description: |-
A relative path to an individual endpoint.
The field name MUST begin with a slash.
The path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL.
Path templating is allowed.
When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
method:
description: the HTTP Method used to process this operation
$ref: './enums.yaml#/definitions/HttpMethod'
mediaType:
type: string
description: must set a media type for the body
servers:
type: array
description: each method must have one or more servers that it is connected to.
items:
$ref: './http.yaml#/definitions/HttpServer'
stream:
type: boolean
enum:
- true
required:
- mediaType
- method
- path
- servers
- stream
HttpStreamResponse:
type: object
properties:
headers:
type: array
description: content returned by the service in the HTTP headers
items:
$ref: './schemas.yaml#/definitions/Schema'
mediaTypes:
type: array
description: the possible media types that this response MUST match one of
items:
type: string
statusCodes:
type: array
description: the possible HTTP status codes that this response MUST match one of.
items:
enum:
- 100
- 101
- 102
- 103
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 226
- 300
- 301
- 302
- 304
- 305
- 306
- 307
- 308
- 400
- 401
- 402
- 403
- 404
- 405
- 406
- 407
- 408
- 409
- 410
- 411
- 412
- 413
- 414
- 415
- 416
- 417
- 418
- 421
- 422
- 423
- 424
- 425
- 426
- 428
- 429
- 431
- 451
- 500
- 501
- 502
- 503
- 504
- 505
- 506
- 507
- 508
- 510
- 511
- default
stream:
type: boolean
description: stream responses
enum:
- true
required:
- headers
- mediaTypes
- statusCodes
- stream
HttpWithBodyRequest:
type: object
properties:
path:
type: string
description: |-
A relative path to an individual endpoint.
The field name MUST begin with a slash.
The path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL.
Path templating is allowed.
When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
method:
description: the HTTP Method used to process this operation
$ref: './enums.yaml#/definitions/HttpMethod'
mediaType:
type: string
description: must set a media type for the body
servers:
type: array
description: each method must have one or more servers that it is connected to.
items:
$ref: './http.yaml#/definitions/HttpServer'
required:
- mediaType
- method
- path
- servers
ImplicitOAuthFlow:
type: object
properties:
authorizationUrl:
type: string
description: an URI
refreshUrl:
type: string
description: an URI
scopes:
$ref: './master.yaml#/definitions/Dictionary<string>'
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- authorizationUrl
- scopes
NonBearerHTTPSecurityScheme:
type: object
properties:
type:
type: string
enum:
- http
description:
type: string
scheme:
type: string
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- scheme
- type
OAuth2SecurityScheme:
type: object
properties:
type:
type: string
enum:
- oauth2
description:
type: string
flows:
$ref: './http.yaml#/definitions/OAuthFlows'
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- flows
- type
OAuthFlows:
type: object
properties:
authorizationCode:
$ref: './http.yaml#/definitions/AuthorizationCodeOAuthFlow'
clientCredentials:
$ref: './http.yaml#/definitions/ClientCredentialsFlow'
implicit:
$ref: './http.yaml#/definitions/ImplicitOAuthFlow'
password:
$ref: './http.yaml#/definitions/PasswordOAuthFlow'
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
OpenIdConnectSecurityScheme:
type: object
properties:
type:
type: string
enum:
- openIdConnect
description:
type: string
openIdConnectUrl:
type: string
description: an URI
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- openIdConnectUrl
- type
PasswordOAuthFlow:
type: object
properties:
refreshUrl:
type: string
description: an URI
scopes:
$ref: './master.yaml#/definitions/Dictionary<string>'
tokenUrl:
type: string
description: an URI
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- scopes
- tokenUrl
SecurityRequirement:
type: object
description: common ways of serializing simple parameters
SecurityScheme:
anyOf:
- $ref: './http.yaml#/definitions/BearerHTTPSecurityScheme'
- $ref: './http.yaml#/definitions/NonBearerHTTPSecurityScheme'
- $ref: './http.yaml#/definitions/OAuth2SecurityScheme'
- $ref: './http.yaml#/definitions/APIKeySecurityScheme'
- $ref: './http.yaml#/definitions/OpenIdConnectSecurityScheme'
ServerVariable:
type: object
description: An object representing a Server Variable for server URL template substitution.
properties:
$key:
type: string
description: common name of the aspect -- in OAI3 this was typically the key in the parent dictionary
schema:
description: the schema for the
anyOf:
- $ref: './schemas.yaml#/definitions/NumberSchema'
- $ref: './schemas.yaml#/definitions/StringSchema'
- $ref: './schemas.yaml#/definitions/ChoiceSchema'
description:
type: string
description: description of the aspect.
default:
type: string
description: 'The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.'
apiVersions:
type: array
description: API versions that this applies to. Undefined means all versions
items:
$ref: './master.yaml#/definitions/ApiVersion'
deprecated:
description: 'deprecation information -- ie, when this aspect doesn''t apply and why'
$ref: './master.yaml#/definitions/Deprecation'
required:
type: boolean
description: if the value is marked 'required'.
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
required:
- $key
- description
- language
- schema
StreamResponse:
type: object
description: a response where the content should be treated as a stream instead of a value or object
properties:
stream:
type: boolean
description: indicates that this response is a stream
enum:
- true
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- language
- protocol
- stream

Просмотреть файл

@ -0,0 +1,646 @@
$schema: 'http://json-schema.org/draft-07/schema#'
definitions:
ApiVersion:
type: object
description: |-
- since API version formats range from
Azure ARM API date style (2018-01-01) to semver (1.2.3)
and virtually any other text, this value tends to be an
opaque string with the possibility of a modifier to indicate
that it is a range.
options:
- prepend a dash or append a plus to indicate a range
(ie, '2018-01-01+' or '-2019-01-01', or '1.0+' )
- semver-range style (ie, '^1.0.0' or '~1.0.0' )
properties:
range:
type: string
enum:
- +
- '-'
version:
type: string
description: the actual api version string used in the API
required:
- version
ApiVersions:
type: array
description: a collection of api versions
items:
$ref: './master.yaml#/definitions/ApiVersion'
CodeModel:
type: object
description: the model that contains all the information required to generate a service api
properties:
schemas:
description: All schemas for the model
$ref: './schemas.yaml#/definitions/Schemas'
info:
description: Code model information
$ref: './master.yaml#/definitions/Info'
operationGroups:
type: array
description: All operations
items:
$ref: './master.yaml#/definitions/OperationGroup'
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- info
- language
- operationGroups
- protocol
- schemas
Contact:
type: object
description: contact information
properties:
name:
type: string
email:
type: string
url:
type: string
description: an URI
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
Deprecation:
type: object
description: represents deprecation information for a given aspect
properties:
apiVersions:
type: array
description: the api versions that this deprecation is applicable to.
items:
$ref: './master.yaml#/definitions/ApiVersion'
message:
type: string
description: the reason why this aspect
required:
- apiVersions
- message
Dictionary<ApiVersion>:
type: object
additionalProperties:
$ref: './master.yaml#/definitions/ApiVersion'
Dictionary<any>:
type: object
additionalProperties: true
Dictionary<string>:
type: object
additionalProperties:
type: string
Discriminator:
type: object
description: Disciminator for polymorphic class hierarchy
properties:
mapping:
$ref: './master.yaml#/definitions/Dictionary<string>'
propertyName:
type: string
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- propertyName
Example:
type: object
description: 'example data [UNFINISHED]'
properties:
description:
type: string
externalValue:
type: string
description: an URI
summary:
type: string
Extensions:
type: object
properties:
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
ExternalDocumentation:
type: object
description: a reference to external documentation
properties:
description:
type: string
url:
type: string
description: an URI
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- url
Info:
type: object
description: code model information
properties:
description:
type: string
description: a text description of the service
contact:
description: contact information for the service
$ref: './master.yaml#/definitions/Contact'
externalDocs:
description: External Documentation
$ref: './master.yaml#/definitions/ExternalDocumentation'
license:
description: license information for th service
$ref: './master.yaml#/definitions/License'
termsOfService:
type: string
description: an uri to the terms of service specified to access the service
title:
type: string
description: the title of this service.
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- title
Language:
type: object
properties:
name:
type: string
description: name used in actual implementation
description:
type: string
description: description text - describes this node.
required:
- description
- name
Languages:
type: object
description: custom extensible metadata for individual language generators
properties:
default:
$ref: './master.yaml#/definitions/Language'
c:
$ref: './master.yaml#/definitions/Language'
cpp:
$ref: './master.yaml#/definitions/Language'
csharp:
$ref: './master.yaml#/definitions/Language'
go:
$ref: './master.yaml#/definitions/Language'
java:
$ref: './master.yaml#/definitions/Language'
javascript:
$ref: './master.yaml#/definitions/Language'
objectivec:
$ref: './master.yaml#/definitions/Language'
powershell:
$ref: './master.yaml#/definitions/Language'
python:
$ref: './master.yaml#/definitions/Language'
ruby:
$ref: './master.yaml#/definitions/Language'
swift:
$ref: './master.yaml#/definitions/Language'
typescript:
$ref: './master.yaml#/definitions/Language'
required:
- default
Languages<SchemaMetadata>:
type: object
description: custom extensible metadata for individual language generators
properties:
default:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
c:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
cpp:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
csharp:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
go:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
java:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
javascript:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
objectivec:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
powershell:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
python:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
ruby:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
swift:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
typescript:
$ref: './schemas.yaml#/definitions/SchemaMetadata'
required:
- default
License:
type: object
description: license information
properties:
name:
type: string
description: the nameof the license
url:
type: string
description: an uri pointing to the full license text
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- name
Metadata:
type: object
description: common pattern for Metadata on aspects
properties:
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- language
- protocol
Operation:
type: object
description: 'represents a single callable endpoint with a discrete set of inputs, and any number of output possibilities (responses or exceptions)'
properties:
$key:
type: string
description:
type: string
apiVersions:
type: array
description: API versions that this applies to. Undefined means all versions
items:
$ref: './master.yaml#/definitions/ApiVersion'
deprecated:
description: 'deprecation information -- ie, when this aspect doesn''t apply and why'
$ref: './master.yaml#/definitions/Deprecation'
exceptions:
type: array
description: responses that indicate a failed call
items:
$ref: './master.yaml#/definitions/Response'
externalDocs:
description: External Documentation Links
$ref: './master.yaml#/definitions/ExternalDocumentation'
profile:
description: the apiVersion to use for a given profile name
$ref: './master.yaml#/definitions/Dictionary<ApiVersion>'
request:
description: the inputs that are used to build the request.
$ref: './master.yaml#/definitions/Request'
responses:
type: array
description: responses that indicate a successful call
items:
$ref: './master.yaml#/definitions/Response'
summary:
type: string
description: a short description
uid:
type: string
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- $key
- description
- exceptions
- language
- profile
- protocol
- request
- responses
- uid
OperationGroup:
type: object
description: an operation group represents a container around set of operations
properties:
$key:
type: string
operations:
type: array
items:
$ref: './master.yaml#/definitions/Operation'
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- $key
- language
- operations
- protocol
Parameter:
type: object
description: a definition of an discrete input for an operation
properties:
$key:
type: string
schema:
description: the schema of this Value
$ref: './schemas.yaml#/definitions/Schema'
description:
type: string
apiVersions:
type: array
description: API versions that this applies to. Undefined means all versions
items:
$ref: './master.yaml#/definitions/ApiVersion'
deprecated:
description: 'deprecation information -- ie, when this aspect doesn''t apply and why'
$ref: './master.yaml#/definitions/Deprecation'
externalDocs:
description: External Documentation Links
$ref: './master.yaml#/definitions/ExternalDocumentation'
nullable:
type: boolean
description: can null be passed in instead
required:
type: boolean
description: if the value is marked 'required'.
summary:
type: string
description: a short description
uid:
type: string
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- $key
- description
- language
- protocol
- schema
- uid
Property:
type: object
description: a property is a child value in an object
properties:
$key:
type: string
schema:
description: the schema of this Value
$ref: './schemas.yaml#/definitions/Schema'
description:
type: string
apiVersions:
type: array
description: API versions that this applies to. Undefined means all versions
items:
$ref: './master.yaml#/definitions/ApiVersion'
deprecated:
description: 'deprecation information -- ie, when this aspect doesn''t apply and why'
$ref: './master.yaml#/definitions/Deprecation'
externalDocs:
description: External Documentation Links
$ref: './master.yaml#/definitions/ExternalDocumentation'
nullable:
type: boolean
description: can null be passed in instead
readOnly:
type: boolean
description: 'if the property is marked read-only (ie, not intended to be sent to the service)'
required:
type: boolean
description: if the value is marked 'required'.
serializedName:
type: string
description: the wire name of this property
summary:
type: string
description: a short description
uid:
type: string
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- $key
- description
- language
- protocol
- schema
- serializedName
- uid
Protocol:
type: object
Protocols:
type: object
description: 'custom extensible metadata for individual protocols (ie, HTTP, etc)'
properties:
amqp:
$ref: './master.yaml#/definitions/Protocol'
jsonrpc:
$ref: './master.yaml#/definitions/Protocol'
mqtt:
$ref: './master.yaml#/definitions/Protocol'
http:
$ref: './master.yaml#/definitions/Protocol'
Request:
type: object
properties:
parameters:
type: array
description: the parameter inputs to the operation
items:
$ref: './master.yaml#/definitions/Parameter'
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- language
- protocol
Response:
type: object
description: a response from a service.
properties:
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- language
- protocol
SchemaMetadata:
type: object
description: language metadata specific to schema instances
properties:
name:
type: string
description: name used in actual implementation
description:
type: string
description: description text - describes this node.
discriminatorValue:
type: string
description: 'if this is a child of a polymorphic class, this will have the value of the descriminator.'
namespace:
type: string
description: namespace of the implementation of this item
required:
- description
- name
SchemaResponse:
type: object
description: a response that should be deserialized into a result of type(schema)
properties:
schema:
description: the content returned by the service for a given operaiton
$ref: './schemas.yaml#/definitions/Schema'
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- language
- protocol
- schema
SerializationFormat:
type: object
properties:
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
SerializationFormats:
type: object
description: custom extensible metadata for individual serialization formats
properties:
json:
$ref: './master.yaml#/definitions/Extensions'
protobuf:
$ref: './master.yaml#/definitions/Extensions'
xml:
$ref: './master.yaml#/definitions/XmlSerlializationFormat'
Value:
type: object
description: 'common base interface for properties, parameters and the like.'
properties:
$key:
type: string
schema:
description: the schema of this Value
$ref: './schemas.yaml#/definitions/Schema'
description:
type: string
apiVersions:
type: array
description: API versions that this applies to. Undefined means all versions
items:
$ref: './master.yaml#/definitions/ApiVersion'
deprecated:
description: 'deprecation information -- ie, when this aspect doesn''t apply and why'
$ref: './master.yaml#/definitions/Deprecation'
externalDocs:
description: External Documentation Links
$ref: './master.yaml#/definitions/ExternalDocumentation'
nullable:
type: boolean
description: can null be passed in instead
required:
type: boolean
description: if the value is marked 'required'.
summary:
type: string
description: a short description
uid:
type: string
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
language:
description: per-language information for this aspect
$ref: './master.yaml#/definitions/Languages'
protocol:
description: per-protocol information for this aspect
$ref: './master.yaml#/definitions/Protocols'
required:
- $key
- description
- language
- protocol
- schema
- uid
XmlSerlializationFormat:
type: object
properties:
name:
type: string
attribute:
type: boolean
namespace:
type: string
prefix:
type: string
wrapped:
type: boolean
extensions:
description: additional metadata extensions dictionary
$ref: './master.yaml#/definitions/Dictionary<any>'
required:
- attribute
- wrapped
email:
type: string
uri:
type: string
description: an URI

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,118 @@
$schema: 'http://json-schema.org/draft-07/schema#'
definitions:
AllSchemaTypes:
type: string
enum:
- and
- array
- boolean
- byte-array
- char
- choice
- constant
- credential
- date
- date-time
- dictionary
- duration
- integer
- number
- object
- odata-query
- or
- string
- unixtime
- uri
- uuid
- xor
AllSchemas:
anyOf:
- $ref: './schemas.yaml#/definitions/NumberSchema'
- $ref: './schemas.yaml#/definitions/StringSchema'
- $ref: './schemas.yaml#/definitions/ObjectSchema'
- $ref: './schemas.yaml#/definitions/BooleanSchema'
- $ref: './schemas.yaml#/definitions/CredentialSchema'
- $ref: './schemas.yaml#/definitions/UriSchema'
- $ref: './schemas.yaml#/definitions/UuidSchema'
- $ref: './schemas.yaml#/definitions/DurationSchema'
- $ref: './schemas.yaml#/definitions/DateTimeSchema'
- $ref: './schemas.yaml#/definitions/DateSchema'
- $ref: './schemas.yaml#/definitions/CharSchema'
- $ref: './schemas.yaml#/definitions/ByteArraySchema'
- $ref: './schemas.yaml#/definitions/UnixTimeSchema'
- $ref: './schemas.yaml#/definitions/AndSchema'
- $ref: './schemas.yaml#/definitions/OrSchema'
- $ref: './schemas.yaml#/definitions/ArraySchema'
- $ref: './schemas.yaml#/definitions/ChoiceSchema'
- $ref: './schemas.yaml#/definitions/DictionarySchema'
- $ref: './schemas.yaml#/definitions/ConstantSchema'
CompoundSchemaTypes:
type: string
enum:
- and
- or
- xor
CompoundSchemas:
anyOf:
- $ref: './schemas.yaml#/definitions/AndSchema'
- $ref: './schemas.yaml#/definitions/OrSchema'
- $ref: './schemas.yaml#/definitions/XorSchema'
ObjectSchemaTypes:
type: string
enum:
- and
- dictionary
- object
- or
ObjectSchemas:
anyOf:
- $ref: './schemas.yaml#/definitions/ObjectSchema'
- $ref: './schemas.yaml#/definitions/AndSchema'
- $ref: './schemas.yaml#/definitions/OrSchema'
- $ref: './schemas.yaml#/definitions/DictionarySchema'
PrimitiveSchemaTypes:
type: string
enum:
- boolean
- char
- credential
- date
- date-time
- duration
- integer
- number
- string
- unixtime
- uri
- uuid
PrimitiveSchemas:
anyOf:
- $ref: './schemas.yaml#/definitions/NumberSchema'
- $ref: './schemas.yaml#/definitions/StringSchema'
- $ref: './schemas.yaml#/definitions/BooleanSchema'
- $ref: './schemas.yaml#/definitions/CredentialSchema'
- $ref: './schemas.yaml#/definitions/UriSchema'
- $ref: './schemas.yaml#/definitions/UuidSchema'
- $ref: './schemas.yaml#/definitions/DurationSchema'
- $ref: './schemas.yaml#/definitions/DateTimeSchema'
- $ref: './schemas.yaml#/definitions/DateSchema'
- $ref: './schemas.yaml#/definitions/CharSchema'
- $ref: './schemas.yaml#/definitions/UnixTimeSchema'
ValueSchemaTypes:
type: string
enum:
- array
- boolean
- byte-array
- char
- choice
- credential
- date
- date-time
- duration
- integer
- number
- string
- unixtime
- uri
- uuid

Просмотреть файл

@ -0,0 +1,272 @@
const { resolve } = require('path');
const jsyaml = require('js-yaml');
const fs = require('fs').promises;
const g = require('glob');
const TJS = require("typescript-json-schema");
const propertyPriority = [
'$key',
'name',
'schemas',
'name',
'type',
'format',
'schema',
'operationId',
'path',
'method',
'description',
'default',
];
const propertyNegativePriority = [
'callbacks',
'http',
'commands',
'operations',
'extensions',
'details',
'language',
'protocol'
];
function sortWithPriorty(a, b) {
if (a == b) {
return 0;
}
const ia = propertyPriority.indexOf(a);
const ib = propertyPriority.indexOf(b);
const na = propertyNegativePriority.indexOf(a);
const nb = propertyNegativePriority.indexOf(b);
const dota = `${a}`.startsWith('.');
const dotb = `${b}`.startsWith('.');
if (dota) {
if (!dotb) {
return 1;
}
}
else {
if (dotb) {
return -1;
}
}
if (na > -1) {
if (nb > -1) {
return na - nb;
}
return 1;
}
if (nb > -1) {
return -1;
}
if (ia != -1) {
return ib != -1 ? ia - ib : -1;
}
return ib != -1 || a > b ? 1 : a < b ? -1 : 0;
}
function deserialize(text, filename) {
return js_yaml_1.safeLoad(text, {
filename,
});
}
function serialize(model) {
return jsyaml.dump(model, {
sortKeys: sortWithPriorty,
schema: jsyaml.DEFAULT_SAFE_SCHEMA,
skipInvalid: true,
lineWidth: 240
}).
replace(/\s*\w*: {}/g, '').
replace(/\s*\w*: \[\]/g, '').
replace(/(\s*- \$key:)/g, '\n$1')
// replace(/(\s*)(language:)/g, '\n$1## ----------------------------------------------------------------------$1$2');
//.replace(/(\s*language:)/g, '\n$1');
}
function fix(txt) {
return txt
.replace(/<Schema<AllSchemaTypes>>/g, '')
.replace(/<Schema<PrimitiveSchemaTypes>>/g, '')
.replace(/Schema\.TSchemaType_1/g, 'NumericSchemaTypes')
.replace(/Schema\.TSchemaType_2/g, 'ObjectSchemaTypes')
.replace(/Schema\.TSchemaType_3/g, 'PrimitiveSchemaTypes')
.replace(/Schema\.TSchemaType/g, 'AllSchemaTypes')
.replace(/T_1/g, 'Language')
.replace(/T_2/g, 'Protocol')
.replace(/Protocols<Protocol>/g, 'Protocols')
}
function fixmodel(schema) {
txt = JSON.stringify(schema);
txt = txt
.replace(/<Schema<AllSchemaTypes>>/g, '')
.replace(/Schema<AllSchemaTypes>/g, 'Schema')
.replace(/<Schema<PrimitiveSchemaTypes>>/g, '')
.replace(/Schema\.TSchemaType_1/g, 'NumericSchemaTypes')
.replace(/Schema\.TSchemaType_2/g, 'ObjectSchemaTypes')
.replace(/Schema\.TSchemaType_3/g, 'PrimitiveSchemaTypes')
.replace(/Schema\.TSchemaType/g, 'AllSchemaTypes')
.replace(/T_1/g, 'Language')
.replace(/T_2/g, 'Protocol')
.replace(/T_3/g, 'Extensions')
.replace(/Protocols<Protocol>/g, 'Protocols')
.replace(/Languages<Language>/g, 'Languages')
.replace(/definitions\/T/g, 'definitions/ApiVersion')
.replace(/ElementType_1/g, 'Schema')
.replace(/ElementType/g, 'Schema')
.replace(/SerializationFormats<SerializationFormat>/g, 'SerializationFormats')
model = JSON.parse(txt, undefined, 2);
return model
}
async function main() {
const settings = {
required: true,
defaultProps: true,
strictNullChecks: true,
excludePrivate: true,
};
const program = TJS.getProgramFromFiles(g.sync(`${__dirname}/../model/**/*.ts`), {}, __dirname);
// We can either get the schema for one file and one type...
let schema = TJS.generateSchema(program, "*", settings);
delete schema.definitions['ValueSchemas'];
delete schema.definitions['ArraySchema<Schema<AllSchemaTypes>>'];
delete schema.definitions['ConstantSchema<Schema<AllSchemaTypes>>'];
delete schema.definitions['DictionarySchema<Schema<AllSchemaTypes>>'];
delete schema.definitions['ChoiceSchema<Schema<PrimitiveSchemaTypes>>'];
delete schema.definitions['Aspect'];
delete schema.definitions['Schema.TSchemaType'];
delete schema.definitions['Schema.TSchemaType_2'];
delete schema.definitions['Languages<Language>'];
delete schema.definitions['T'];
delete schema.definitions['ElementType'];
delete schema.definitions['ElementType_1'];
delete schema.definitions['SerializationFormats<SerializationFormat>'];
schema.definitions['Dictionary<string>'].additionalProperties = { type: 'string' }
schema.definitions['Dictionary<any>'].additionalProperties = true;
for (let each in schema.definitions) {
if (schema.definitions[each].type === 'number') {
delete schema.definitions[each];
}
}
// write out the full all in one model
await writemodels('code-model', 'all-in-one', schema);
schema = JSON.parse(JSON.stringify(schema).replace(/#\/definitions(.*?)"/g, './master.json#/definitions$1"'));
// split them up:
const all = {
master: schema,
enums: {
$schema: 'http://json-schema.org/draft-07/schema#',
definitions: {}
},
schemas: {
$schema: 'http://json-schema.org/draft-07/schema#',
definitions: {}
},
types: {
$schema: 'http://json-schema.org/draft-07/schema#',
definitions: {}
},
http: {
$schema: 'http://json-schema.org/draft-07/schema#',
definitions: {}
}
}
//move schemas
for (let each in all.master.definitions) {
if (each.endsWith('Schema') || each.startsWith('Schema<')) {
moveTo(all, each, 'schemas')
}
}
moveTo(all, 'Schemas', 'schemas');
moveTo(all, 'ChoiceType', 'schemas');
moveTo(all, 'ChoiceValue', 'schemas');
moveTo(all, 'ConstantType', 'schemas');
moveTo(all, 'ConstantValue', 'schemas');
for (let each in all.master.definitions) {
if (each.endsWith('Schemas')) {
moveTo(all, each, 'types')
}
}
// move types
for (let each in all.master.definitions) {
if (each.endsWith('Types')) {
moveTo(all, each, 'types')
}
}
//move enums
for (let each in all.master.definitions) {
if (all.master.definitions[each].enum) {
moveTo(all, each, 'enums')
}
}
for (let each in all.master.definitions) {
if (['APIKeySecurityScheme',
'BearerHTTPSecurityScheme',
'AuthorizationCodeOAuthFlow',
'HTTPSecurityScheme',
'ImplicitOAuthFlow',
'NonBearerHTTPSecurityScheme',
'OAuth2SecurityScheme',
'OAuthFlows',
'OpenIdConnectSecurityScheme',
'PasswordOAuthFlow',
'SecurityRequirement',
'SecurityScheme',
'ServerVariable',
'Server',
'StreamResponse',
'ClientCredentialsFlow',
].indexOf(each) > -1 || each.startsWith('Http')) {
moveTo(all, each, 'http')
}
}
for (const each in all) {
await writemodels(each, 'model', all[each]);
}
}
function moveTo(all, name, target, ) {
all[target].definitions[name] = all.master.definitions[name];
delete all.master.definitions[name];
for (const each in all) {
all[each] = JSON.parse(JSON.stringify(all[each]).replace(new RegExp(`./master.json(#\/definitions\/${name})`, 'g'), `./${target}.json$1`));
}
}
async function writemodels(name, folder, schema) {
schema = fixmodel(schema);
const yaml = serialize(schema);
const json = JSON.stringify(schema, undefined, 2);
await fs.writeFile(`${__dirname}/../.resources/${folder}/yaml/${name}.yaml`, yaml.replace(/\.json/g, '.yaml'));
await fs.writeFile(`${__dirname}/../.resources/${folder}/json/${name}.json`, json);
}
main();

Просмотреть файл

@ -28,4 +28,6 @@ export * from './model/http/ParameterLocation';
export * from './model/http/security';
export * from './model/http/SerializationStyle';
export * from './model/http/server';
export * from './model/http/status-code';
export * from './model/http/status-code';
export * from './model/yaml-schema';
export * from './tag';

Просмотреть файл

@ -15,8 +15,11 @@
export interface ApiVersion {
/** the actual api version string used in the API */
version: string;
range: '-' | '+' | undefined;
range?: '-' | '+';
}
export class ApiVersion implements ApiVersion {
}
/** a collection of api versions */
export type ApiVersions = Array<ApiVersion>;

Просмотреть файл

@ -2,8 +2,9 @@ import { Metadata } from './metadata';
import { Schemas } from './schemas';
import { Info } from './info';
import { OperationGroup } from './operation';
import { Initializer, DeepPartial, enableSourceTracking } from '@azure-tools/codegen';
import { threadId } from 'worker_threads';
import { DeepPartial, enableSourceTracking } from '@azure-tools/codegen';
// + ADD DISCRIMINATORS TO ALL CLASS.
/** the model that contains all the information required to generate a service api */
export interface CodeModel extends Metadata {
@ -17,6 +18,7 @@ export interface CodeModel extends Metadata {
operationGroups: Array<OperationGroup>;
}
export class CodeModel extends Metadata implements CodeModel {
constructor(title: string, sourceTracking = false, objectInitializer?: DeepPartial<CodeModel>) {
super();

Просмотреть файл

@ -17,3 +17,8 @@ export interface Languages<T extends Language = Language> {
swift?: T;
objectivec?: T;
}
export class Languages implements Languages {
}

Просмотреть файл

@ -3,6 +3,7 @@ import { Extensions } from './extensions';
import { Languages } from './languages';
import { Protocols } from './protocols';
import { Initializer, DeepPartial } from '@azure-tools/codegen';
import { SetType } from '../../tag';
/** common pattern for Metadata on aspects */
export interface Metadata extends Extensions {
@ -13,19 +14,20 @@ export interface Metadata extends Extensions {
protocol: Protocols;
}
export class Metadata extends Initializer implements Metadata {
constructor(objectInitializer?: DeepPartial<Metadata>) {
super();
this.language = {
this.language = SetType(Languages, {
default: {
name: '',
description: ''
}
};
});
this.protocol = {
this.protocol = SetType(Protocols, {
};
});
this.apply(objectInitializer);
}
}
@ -42,3 +44,6 @@ export interface Language extends Dictionary<any> {
/** the bare-minimum fields for per-protocol metadata on a given aspect */
export interface Protocol extends Dictionary<any> {
}
export class Protocol implements Protocol {
}

Просмотреть файл

@ -9,8 +9,8 @@ import { DeepPartial, Initializer } from '@azure-tools/codegen';
/** represents a single callable endpoint with a discrete set of inputs, and any number of output possibilities (responses or exceptions) */
export interface Operation extends Aspect {
/** the inputs to the operation */
parameters: Array<Parameter>;
/** the inputs that are used to build the request. */
request: Request;
/** responses that indicate a successful call */
responses: Array<Response>;
@ -23,9 +23,15 @@ export interface Operation extends Aspect {
}
export class Operation extends Aspect implements Operation {
constructor(public $key: string, public description: string, initializer?: DeepPartial<Operation>) {
super($key, description);
export interface Request extends Metadata {
/** the parameter inputs to the operation */
parameters?: Array<Parameter>;
}
export class Request extends Metadata implements Request {
constructor(initializer?: DeepPartial<Operation>) {
super();
this.apply(initializer);
}
@ -33,6 +39,16 @@ export class Operation extends Aspect implements Operation {
(this.parameters = this.parameters || []).push(parameter);
return parameter;
}
}
export class Operation extends Aspect implements Operation {
constructor(public $key: string, public description: string, initializer?: DeepPartial<Operation>) {
super($key, description);
this.apply({
request: new Request()
}, initializer);
}
addResponse(response: Response) {
(this.responses = this.responses || []).push(response);
return response;

Просмотреть файл

@ -6,6 +6,7 @@
import { Value } from './value';
import { DeepPartial } from '@azure-tools/codegen';
import { uid } from './uid';
import { Schema } from './schema';
/** a definition of an discrete input for an operation */
export interface Parameter extends Value {
@ -13,8 +14,8 @@ export interface Parameter extends Value {
}
export class Parameter extends Value implements Parameter {
constructor(name: string, description: string, initializer?: DeepPartial<Parameter>) {
super(name, description);
constructor(name: string, description: string, schema: Schema, initializer?: DeepPartial<Parameter>) {
super(name, description, schema);
this.language.default.uid = `parameter:${uid()}`;
this.apply(initializer);

Просмотреть файл

@ -2,6 +2,7 @@ import { uid } from './uid';
import { Initializer, DeepPartial } from '@azure-tools/codegen';
import { Value } from './value';
import { Schema } from './schema';
/** a property is a child value in an object */
export interface Property extends Value {
@ -16,8 +17,8 @@ export interface Property extends Value {
export class Property extends Value implements Property {
constructor(name: string, description: string, initializer?: DeepPartial<Property>) {
super(name, description);
constructor(name: string, description: string, schema: Schema, initializer?: DeepPartial<Property>) {
super(name, description, schema);
this.serializedName = name;
this.language.default.uid = `property:${uid()}`;

Просмотреть файл

@ -8,3 +8,7 @@ export interface Protocols<T extends Protocol = Protocol> {
mqtt?: T;
jsonrpc?: T;
}
export class Protocols implements Protocols {
}

Просмотреть файл

@ -3,6 +3,17 @@ import { Schema } from './schema';
/** a response from a service. */
export interface Response extends Metadata {
}
/** a response where the content should be treated as a stream instead of a value or object */
export interface StreamResponse extends Response {
/** indicates that this response is a stream */
stream: true;
}
/** a response that should be deserialized into a result of type(schema) */
export interface SchemaResponse extends Response {
/** the content returned by the service for a given operaiton */
schema: Schema;
}

Просмотреть файл

@ -26,9 +26,42 @@ export enum SchemaType {
/** an object of some type */
Object = 'object',
/** a string */
/** a string of characters */
String = 'string',
/** UnixTime */
UnixTime = 'unixtime',
/** ByteArray -- an array of bytes */
ByteArray = 'byte-array',
/* a binary stream */
Stream = 'stream',
/** a single character */
Char = 'char',
/** a Date */
Date = 'date',
/** a DateTime */
DateTime = 'date-time',
/** a Duration */
Duration = 'duration',
/** a universally unique identifier */
Uuid = 'uuid',
/** an URI of some kind */
Uri = 'uri',
/** a password or credential */
Credential = 'credential',
/** OData Query */
ODataQuery = 'odata-query',
/** a choice between one of several values (ie, 'enum')
*
* @description - this is essentially can be thought of as an 'enum'
@ -68,6 +101,14 @@ export type CompoundSchemaTypes =
/** Schema types that are primitive language values */
export type PrimitiveSchemaTypes =
SchemaType.Char |
SchemaType.Date |
SchemaType.DateTime |
SchemaType.Duration |
SchemaType.Credential |
SchemaType.UnixTime |
SchemaType.Uri |
SchemaType.Uuid |
SchemaType.Boolean |
SchemaType.Integer |
SchemaType.Number |
@ -75,6 +116,7 @@ export type PrimitiveSchemaTypes =
/** schema types that are non-object or complex types */
export type ValueSchemaTypes =
SchemaType.ByteArray |
PrimitiveSchemaTypes |
SchemaType.Array |
SchemaType.Choice;
@ -88,4 +130,4 @@ export type ObjectSchemaTypes =
/** all schema types */
export type AllSchemaTypes =
ValueSchemaTypes | ObjectSchemaTypes | SchemaType.Constant;
ValueSchemaTypes | ObjectSchemaTypes | SchemaType.Constant | SchemaType.ODataQuery | SchemaType.Xor;

Просмотреть файл

@ -32,9 +32,6 @@ export interface Schema<TSchemaType extends SchemaType = AllSchemaTypes> extends
/** the schema type */
type: TSchemaType;
/** sub-type information */
format?: string;
/* short description */
summary?: string;
@ -79,6 +76,8 @@ export function isNumberSchema(schema: Schema): schema is NumberSchema {
/** a Schema that represents a Number value */
export interface NumberSchema extends Schema<SchemaType.Number | SchemaType.Integer> {
/** precision (# of bits?) of the number */
precision: number;
/** if present, the number must be an exact multiple of this value */
multipleOf?: number;
@ -96,6 +95,13 @@ export interface NumberSchema extends Schema<SchemaType.Number | SchemaType.Inte
exclusiveMinimum?: boolean;
}
export class NumberSchema extends Schema<SchemaType.Number | SchemaType.Integer> implements NumberSchema {
constructor(name: string, description: string, type: SchemaType.Number | SchemaType.Integer, precision: number, objectInitializer?: DeepPartial<NumberSchema>) {
super(name, description, type);
this.apply({ precision }, objectInitializer);
}
}
/** a Schema that represents a string value */
export interface StringSchema extends Schema<SchemaType.String> {
@ -160,6 +166,12 @@ export class ObjectSchema extends Schema<SchemaType.Object> implements ObjectSch
super(name, description, SchemaType.Object);
this.apply(objectInitializer);
}
addProperty(property: Property) {
(this.properties = this.properties || []).push(property);
return property;
}
}
@ -175,6 +187,10 @@ export interface ChoiceValue {
description: string;
}
export class ChoiceValue {
}
/** a schema that represents a choice of several values (ie, an 'enum') */
export interface ChoiceSchema<ChoiceType extends Schema = Schema<PrimitiveSchemaTypes>> extends Schema<SchemaType.Choice> {
/** the primitive type for the choices */
@ -228,6 +244,130 @@ export class BooleanSchema extends Schema<SchemaType.Boolean> implements Boolean
}
}
/** a schema that represents a ODataQuery value */
export interface ODataQuerySchema extends Schema<SchemaType.ODataQuery> { }
export class ODataQuerySchema extends Schema<SchemaType.ODataQuery> implements ODataQuerySchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<ODataQuerySchema>) {
super(name, description, SchemaType.ODataQuery);
this.apply(objectInitializer);
}
}
/** a schema that represents a Credential value */
export interface CredentialSchema extends Schema<SchemaType.Credential> {
/** the maximum length of the string */
maxLength?: number;
/** the minimum length of the string */
minLength?: number;
/** a regular expression that the string must be validated against */
pattern?: string; // regex
}
export class CredentialSchema extends Schema<SchemaType.Credential> implements CredentialSchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<CredentialSchema>) {
super(name, description, SchemaType.Credential);
this.apply(objectInitializer);
}
}
/** a schema that represents a Uri value */
export interface UriSchema extends Schema<SchemaType.Uri> {
/** the maximum length of the string */
maxLength?: number;
/** the minimum length of the string */
minLength?: number;
/** a regular expression that the string must be validated against */
pattern?: string; // regex
}
export class UriSchema extends Schema<SchemaType.Uri> implements UriSchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<UriSchema>) {
super(name, description, SchemaType.Uri);
this.apply(objectInitializer);
}
}
/** a schema that represents a Uuid value */
export interface UuidSchema extends Schema<SchemaType.Uuid> { }
export class UuidSchema extends Schema<SchemaType.Uuid> implements UuidSchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<UuidSchema>) {
super(name, description, SchemaType.Uuid);
this.apply(objectInitializer);
}
}
/** a schema that represents a Duration value */
export interface DurationSchema extends Schema<SchemaType.Duration> { }
export class DurationSchema extends Schema<SchemaType.Duration> implements DurationSchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<DurationSchema>) {
super(name, description, SchemaType.Duration);
this.apply(objectInitializer);
}
}
/** a schema that represents a DateTime value */
export interface DateTimeSchema extends Schema<SchemaType.DateTime> {
/** date-time format */
format: 'date-time-rfc1123' | 'date-time';
}
export class DateTimeSchema extends Schema<SchemaType.DateTime> implements DateTimeSchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<DateTimeSchema>) {
super(name, description, SchemaType.DateTime);
this.apply(objectInitializer);
}
}
/** a schema that represents a Date value */
export interface DateSchema extends Schema<SchemaType.Date> { }
export class DateSchema extends Schema<SchemaType.Date> implements DateSchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<DateSchema>) {
super(name, description, SchemaType.Date);
this.apply(objectInitializer);
}
}
/** a schema that represents a Char value */
export interface CharSchema extends Schema<SchemaType.Char> { }
export class CharSchema extends Schema<SchemaType.Char> implements CharSchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<CharSchema>) {
super(name, description, SchemaType.Char);
this.apply(objectInitializer);
}
}
/** a schema that represents a ByteArray value */
export interface ByteArraySchema extends Schema<SchemaType.ByteArray> {
/** date-time format */
format: 'base64url' | 'byte';
}
export class ByteArraySchema extends Schema<SchemaType.ByteArray> implements ByteArraySchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<ByteArraySchema>) {
super(name, description, SchemaType.ByteArray);
this.apply(objectInitializer);
}
}
/** a schema that represents a UnixTime value */
export interface UnixTimeSchema extends Schema<SchemaType.UnixTime> { }
export class UnixTimeSchema extends Schema<SchemaType.UnixTime> implements UnixTimeSchema {
constructor(name: string, description: string, objectInitializer?: DeepPartial<UnixTimeSchema>) {
super(name, description, SchemaType.UnixTime);
this.apply(objectInitializer);
}
}
/** a schema that represents a key-value collection */
export interface DictionarySchema<ElementType extends Schema = Schema<AllSchemaTypes>> extends Schema<SchemaType.Dictionary> {
/** the element type of the dictionary. (Keys are always strings) */

Просмотреть файл

@ -1,5 +1,5 @@
import { PrimitiveSchemaTypes, CompoundSchemaTypes } from './schema-type';
import { ObjectSchema, ChoiceSchema, DictionarySchema, ConstantSchema, ArraySchema, AndSchema, OrSchema, XorSchema, BooleanSchema, NumberSchema, StringSchema } from './schema';
import { ObjectSchema, ChoiceSchema, DictionarySchema, ConstantSchema, ArraySchema, AndSchema, OrSchema, XorSchema, BooleanSchema, NumberSchema, StringSchema, DateSchema, DateTimeSchema, UnixTimeSchema, CredentialSchema, UriSchema, UuidSchema, DurationSchema, CharSchema, ByteArraySchema } from './schema';
/** the full set of schemas for a given service, categorized into convenient collections */
export interface Schemas {
@ -7,7 +7,7 @@ export interface Schemas {
objects?: Array<ObjectSchema>;
/** schemas that construct more complex schemas based on compound construction (ie, allOf, oneOf, anyOf) */
compounds?: Array<CompoundSchemaTypes>;
compounds?: Array<CompoundSchemas>;
/** schemas that represent a set of choices (ie, 'enum') */
choices?: Array<ChoiceSchema>;
@ -22,7 +22,7 @@ export interface Schemas {
*
* @note - the important bits in these are the validation restrictions that may be present.
*/
primitives?: Array<PrimitiveSchemas>;
primitives?: Array<PrimitiveSchemas | ValueSchemas>;
}
export type CompoundSchemas =
@ -33,12 +33,20 @@ export type CompoundSchemas =
/** Schema types that are primitive language values */
export type PrimitiveSchemas =
BooleanSchema |
DateSchema |
DateTimeSchema |
UnixTimeSchema |
CredentialSchema |
UriSchema |
UuidSchema |
DurationSchema |
CharSchema |
NumberSchema |
StringSchema |
ArraySchema;
StringSchema;
/** schema types that are non-object or complex types */
export type ValueSchemas =
ByteArraySchema |
PrimitiveSchemas |
ArraySchema |
ChoiceSchema;
@ -56,8 +64,28 @@ export type AllSchemas =
export class Schemas {
addPrimitive<T extends PrimitiveSchemas>(schema: T): T {
this.primitives || (this.primitives = new Array<PrimitiveSchemas>()).push(schema);
addPrimitive<T extends ValueSchemas>(schema: T): T {
this.primitives || (this.primitives = new Array<ValueSchemas>()).push(schema);
return schema;
}
addObject<T extends ObjectSchema>(schema: T): T {
(this.objects || (this.objects = new Array<ObjectSchema>())).push(schema);
return schema;
}
addCompound<T extends CompoundSchemas>(schema: T): T {
(this.compounds || (this.compounds = new Array<CompoundSchemas>())).push(schema);
return schema;
}
addChoice<T extends ChoiceSchema>(schema: T): T {
(this.choices || (this.choices = new Array<ChoiceSchema>())).push(schema);
return schema;
}
addDictionary<T extends DictionarySchema>(schema: T): T {
(this.dictionaries || (this.dictionaries = new Array<DictionarySchema>())).push(schema);
return schema;
}
addConstant<T extends ConstantSchema>(schema: T): T {
(this.constants || (this.constants = new Array<ConstantSchema>())).push(schema);
return schema;
}
}

Просмотреть файл

@ -13,8 +13,9 @@ export interface Value extends Aspect {
}
export class Value extends Aspect implements Value {
constructor(public $key: string, public description: string, initializer?: DeepPartial<Value>) {
constructor(public $key: string, public description: string, schema: Schema, initializer?: DeepPartial<Value>) {
super($key, description);
this.schema = schema;
this.apply(initializer);
}
}

Просмотреть файл

@ -6,66 +6,118 @@ import { StatusCode } from './status-code';
import { HttpServer } from './server';
import { SecurityRequirement } from './security';
import { Schema } from '../common/schema';
import { Request } from '../common/operation';
export enum ImplementationLocation {
Method = 'Method',
Client = 'Client',
}
export namespace Http {
/** extended metadata for HTTP operation parameters */
export interface ParameterProtocol extends Protocol {
/** the location that this parameter is placed in the http request */
in: ParameterLocation;
/** the Serialization Style used for the parameter. */
style: SerializationStyle;
/** extended metadata for HTTP operation parameters */
export interface HttpParameter extends Protocol {
/** the location that this parameter is placed in the http request */
in: ParameterLocation;
/** when set, this indicates that the content of the parameter should not be subject to URI encoding rules. */
skipUriEncoding?: boolean;
/** the Serialization Style used for the parameter. */
style: SerializationStyle;
/** suggested implementation location for this parameter */
implementation: ImplementationLocation;
}
/** when set, this indicates that the content of the parameter should not be subject to URI encoding rules. */
skipUriEncoding?: boolean;
/** HTTP operation protocol data */
export interface OperationProtocol extends Protocol {
/** A relative path to an individual endpoint.
*
* The field name MUST begin with a slash.
* The path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL.
* Path templating is allowed.
*
* When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. */
path: string;
/** suggested implementation location for this parameter */
implementation: ImplementationLocation;
}
/** the HTTP Method used to process this operation */
method: HttpMethod;
export class HttpParameter extends Protocol {
/** each method must have one or more servers that it is connected to. */
servers: Array<HttpServer>;
}
}
/** HTTP operation protocol data */
export interface HttpRequest extends Protocol {
/** A relative path to an individual endpoint.
*
* The field name MUST begin with a slash.
* The path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL.
* Path templating is allowed.
*
* When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. */
path: string;
export interface ResponseProtocol extends Protocol {
/** the possible HTTP status codes that this response MUST match one of. */
statusCodes: Array<StatusCode>; // oai3 supported options.
/** the HTTP Method used to process this operation */
method: HttpMethod;
/** the possible media types that this response MUST match one of */
mediaTypes: Array<string>; // the response mediaTypes that this should apply to (ie, 'application/json')
/** each method must have one or more servers that it is connected to. */
servers: Array<HttpServer>;
}
/** content returned by the service in the HTTP headers */
headers: Array<Schema>;
export class HttpRequest extends Protocol {
}
export interface HttpWithBodyRequest extends HttpRequest {
/** must set a media type for the body */
mediaType: string;
}
export class HttpWithBodyRequest extends HttpRequest implements HttpWithBodyRequest {
}
export interface HttpStreamRequest extends HttpWithBodyRequest {
/* indicates that the HTTP request should be a stream, not a serialized object */
stream: true;
}
export class HttpStreamRequest extends HttpWithBodyRequest implements HttpStreamRequest {
}
export interface HttpMultiPartRequest extends HttpWithBodyRequest {
/** indicates that the HTTP Request should be a multipart request
*
* ie, that it has multiple requests in a single request.
*/
multipart: true;
/** the multiple request parts that make up this request ?? is this right? */
parts: Array<Request>;
}
}
export class HttpMultipartRequest extends HttpWithBodyRequest implements HttpMultiPartRequest {
multipart = <true>true;
parts = [];
}
/** code model metadata for HTTP protocol */
export interface ModelProtocol extends Protocol {
/** a collection of server definitions for the service */
servers: Array<HttpServer>;
export interface HttpResponse extends Protocol {
/** the possible HTTP status codes that this response MUST match one of. */
statusCodes: Array<StatusCode>; // oai3 supported options.
/** a collection of security requirements for the service */
security?: Array<SecurityRequirement>;
}
/** the possible media types that this response MUST match one of */
mediaTypes: Array<string>; // the response mediaTypes that this should apply to (ie, 'application/json')
}
/** content returned by the service in the HTTP headers */
headers: Array<Schema>;
}
export class HttpResponse extends Protocol implements HttpResponse {
}
export interface HttpStreamResponse extends HttpResponse {
/** stream responses */
stream: true;
}
export class HttpStreamResponse extends HttpResponse implements HttpStreamResponse {
}
/** code model metadata for HTTP protocol */
export interface HttpModel extends Protocol {
/** a collection of server definitions for the service */
servers: Array<HttpServer>;
/** a collection of security requirements for the service */
security?: Array<SecurityRequirement>;
}
export class HttpModel extends Protocol implements HttpModel {
}

Просмотреть файл

@ -0,0 +1,91 @@
import { Schema, Type, DEFAULT_SAFE_SCHEMA } from 'js-yaml';
import { CodeModel } from './common/code-model';
import { Metadata } from './common/metadata';
import { Parameter } from './common/parameter';
import { Property } from './common/property';
import { Value } from './common/value';
import { Operation, Request, OperationGroup } from './common/operation';
import { NumberSchema, StringSchema, ArraySchema, ObjectSchema, ChoiceSchema, ConstantSchema, BooleanSchema, ODataQuerySchema, CredentialSchema, UriSchema, UuidSchema, DurationSchema, DateTimeSchema, DateSchema, CharSchema, ByteArraySchema, UnixTimeSchema, DictionarySchema, AndSchema, OrSchema, XorSchema, ChoiceValue } from './common/schema';
import { Aspect } from './common/aspect';
import { Schemas } from './common/schemas';
import { Discriminator } from './common/discriminator';
import { ExternalDocumentation } from './common/external-documentation';
import { Contact, Info, License } from './common/info';
import { APIKeySecurityScheme, BearerHTTPSecurityScheme, ImplicitOAuthFlow, NonBearerHTTPSecurityScheme, OAuth2SecurityScheme, OAuthFlows, OpenIdConnectSecurityScheme, PasswordOAuthFlow, AuthorizationCodeOAuthFlow, ClientCredentialsFlow } from './http/security';
import { HttpServer, ServerVariable } from './http/server';
import { Languages } from './common/languages';
import { Protocols } from './common/protocols';
import { ApiVersion } from './common/api-version';
import { HttpWithBodyRequest, HttpParameter, HttpStreamRequest, HttpMultipartRequest, HttpStreamResponse, HttpRequest, HttpResponse, HttpModel } from './http/http';
function TypeInfo<U extends new (...args: any) => any>(type: U) {
return new Type(`!${type.name}`, { kind: 'mapping', instanceOf: type, construct: (i) => Object.setPrototypeOf(i, type.prototype) });
}
export const codeModelSchema = Schema.create(DEFAULT_SAFE_SCHEMA, [
TypeInfo(HttpModel),
TypeInfo(HttpWithBodyRequest),
TypeInfo(HttpParameter),
TypeInfo(HttpRequest),
TypeInfo(HttpStreamRequest),
TypeInfo(HttpMultipartRequest),
TypeInfo(HttpResponse),
TypeInfo(HttpStreamResponse),
TypeInfo(Parameter),
TypeInfo(Property),
TypeInfo(Value),
TypeInfo(Operation),
TypeInfo(NumberSchema),
TypeInfo(StringSchema),
TypeInfo(ArraySchema),
TypeInfo(ObjectSchema),
TypeInfo(ChoiceValue),
new Type('!ChoiceSchema', { kind: 'mapping', instanceOf: ChoiceSchema, construct: (i) => Object.setPrototypeOf(i, ChoiceSchema.prototype) }),
TypeInfo(ConstantSchema),
TypeInfo(BooleanSchema),
TypeInfo(ODataQuerySchema),
TypeInfo(CredentialSchema),
TypeInfo(UriSchema),
TypeInfo(UuidSchema),
TypeInfo(DurationSchema),
TypeInfo(DateTimeSchema),
TypeInfo(DateSchema),
TypeInfo(CharSchema),
TypeInfo(ByteArraySchema),
TypeInfo(UnixTimeSchema),
TypeInfo(DictionarySchema),
TypeInfo(AndSchema),
TypeInfo(OrSchema),
TypeInfo(XorSchema),
TypeInfo(Schema),
TypeInfo(Aspect),
TypeInfo(CodeModel),
TypeInfo(Request),
TypeInfo(Schemas),
TypeInfo(Discriminator),
TypeInfo(ExternalDocumentation),
TypeInfo(Contact),
TypeInfo(Info),
TypeInfo(License),
TypeInfo(Metadata),
TypeInfo(OperationGroup),
TypeInfo(APIKeySecurityScheme),
TypeInfo(BearerHTTPSecurityScheme),
TypeInfo(ImplicitOAuthFlow),
TypeInfo(NonBearerHTTPSecurityScheme),
TypeInfo(OAuth2SecurityScheme),
TypeInfo(OAuthFlows),
TypeInfo(OpenIdConnectSecurityScheme),
TypeInfo(PasswordOAuthFlow),
TypeInfo(AuthorizationCodeOAuthFlow),
TypeInfo(ClientCredentialsFlow),
TypeInfo(HttpServer),
TypeInfo(ServerVariable),
TypeInfo(Languages),
TypeInfo(Protocols),
TypeInfo(ApiVersion),
]);

Просмотреть файл

@ -43,7 +43,10 @@
"@typescript-eslint/eslint-plugin": "~2.0.0",
"@typescript-eslint/parser": "~2.0.0",
"eslint": "~6.2.2",
"typescript": "~3.6.2"
"typescript": "~3.6.2",
"glob": "~7.1.4",
"js-yaml": "3.13.1",
"typescript-json-schema": "~0.40.0"
},
"dependencies": {
"@azure-tools/autorest-extension-base": "~3.1.0",

3
codemodel/tag.ts Normal file
Просмотреть файл

@ -0,0 +1,3 @@
export function SetType<U extends new (...args: any) => any>(prototype: U, instance: any): InstanceType<U> {
return instance && (<any>prototype).prototype ? Object.setPrototypeOf(instance, (<any>prototype).prototype) : instance;
}

Просмотреть файл

@ -11,6 +11,7 @@
"."
],
"exclude": [
".scripts",
"dist",
"resources",
"node_modules",

Просмотреть файл

@ -26,6 +26,7 @@ export interface IterableWithLinq<T> extends Iterable<T> {
forEach(action: (each: T) => void): void;
aggregate<A, R>(accumulator: (current: T | A, next: T) => A, seed?: T | A, resultAction?: (result?: T | A) => A | R): T | A | R | undefined;
toArray(): Array<T>;
results(): Promise<void>;
/**
* Gets or sets the length of the iterable. This is a number one higher than the highest element defined in an array.
@ -62,7 +63,8 @@ function linqify<T>(iterable: Iterable<T>): IterableWithLinq<T> {
forEach: <any>forEach.bind(iterable),
aggregate: <any>aggregate.bind(iterable),
join: <any>join.bind(iterable),
count: len.bind(iterable)
count: len.bind(iterable),
results: <any>results.bind(iterable),
};
r.linq = r;
return r;
@ -292,6 +294,12 @@ function toArray<T>(this: Iterable<T>): Array<T> {
return [...this];
}
async function results<T>(this: Iterable<T>): Promise<void> {
await Promise.all([...<any>this]);
}
function join<T>(this: Iterable<T>, separator: string): string {
return [...this].join(separator);
}

Просмотреть файл

@ -37,7 +37,7 @@ export function typeOf(obj: any) {
/** identifies if a given refable is a reference or an instance */
export function isReference<T>(item: Refable<T>): item is PathReference<T> {
return (<PathReference<T>>item).$ref ? true : false;
return item && (<PathReference<T>>item).$ref ? true : false;
}
/** gets an object instance for the item, regardless if it's a reference or not. */

75
openapi/formats.ts Normal file
Просмотреть файл

@ -0,0 +1,75 @@
export enum StringFormat {
/** @description Standard string format */
None = '',
/** @description A single character */
Char = 'char',
/** @description A base64 string of characters. Represents a byte array */
Byte = 'byte',
/**
* @description Any sequence of octets. (ie, a sequence of unencoded bytes)
* This may not be used for a parameter or property, as it represents a sequence of bytes,
* it may only be used as for a request or response body, and must be used with an appropriate content-type
*/
Binary = 'binary',
/** @description A date as defined by full-date - RFC3339 */
Date = 'date',
/** @description A Date-Time as defined by date-time - RFC3339 */
DateTime = 'date-time',
/** @description A hint to UIs to obscure input. */
Password = 'password',
/** @description a A Date-Time as defined by date-time - RFC1123 */
DateTimeRfc1123 = 'date-time-rfc1123',
/** @description a duration of time (todo: RFC reference? ) */
Duration = 'duration',
/** @description a Universally Unique Identifier ( ISO/IEC 11578:1996) */
Uuid = 'uuid',
/** @description a base64url string of characters, represented as a byte array (see RFC 4648 ) */
Base64Url = 'base64url',
/** @description a string that should be an URL */
Url = 'url',
/** @description an encoded odata query string */
OData = 'odata-query',
Certificate = 'certificate',
}
export enum IntegerFormat {
/** @description an integer value (a javascript representation of maximum safe value is (2^53 - 1). ) */
None = '',
/** @description an explicity declared 32 bit integer */
Int32 = 'int32',
/** @description an explicity declared 64 bit integer */
Int64 = 'int64',
/** @description a UnixTime (number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970) */
UnixTime = 'unixtime'
}
export enum NumberFormat {
/** @description - any number */
None = '',
/** @description - a 32 bit-precision floating point value */
Float = 'float',
/** @description - a 64 bit-precision floating point value */
Double = 'double',
/** @description - a 128 bit-precision floating point value */
Decimal = 'decimal'
}

Просмотреть файл

@ -4,4 +4,5 @@
*--------------------------------------------------------------------------------------------*/
export * from './oai3';
export * from './common';
export * from './common';
export * from './formats';