@azure-tools/codemodel-v3
Version:
AutoRest code model library
178 lines • 6.62 kB
JavaScript
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpComponents = exports.Callback = exports.isHttpOperation = exports.HttpOperationParameter = exports.HttpOperation = exports.NewResponse = exports.HttpMethod = exports.EncodingStyle = exports.ParameterLocation = exports.Response = exports.RequestBody = exports.MediaType = exports.Header = exports.Encoding = void 0;
const components_1 = require("./components");
const extensions_1 = require("./extensions");
const linq_1 = require("@azure-tools/linq");
const uid_1 = require("./uid");
/**
* An encoding attribute is introduced to give you control over the serialization of parts of multipart request bodies.
* This attribute is only applicable to multipart and application/x-www-form-urlencoded request bodies.
*/
class Encoding extends extensions_1.Extensions {
constructor(key, initializer) {
super();
this.key = key;
this.headers = new Array();
this.apply(initializer);
}
}
exports.Encoding = Encoding;
class Header extends extensions_1.Extensions {
constructor(initializer) {
super();
this.content = new Array();
this.apply(initializer);
}
}
exports.Header = Header;
class MediaType extends extensions_1.Extensions {
constructor(key, initializer) {
super();
this.key = key;
this.encoding = new Array();
this.accepts = new Array();
this.apply(initializer);
}
}
exports.MediaType = MediaType;
class RequestBody extends extensions_1.Extensions {
constructor(initializer) {
super();
this.apply(initializer);
}
}
exports.RequestBody = RequestBody;
class Response extends extensions_1.Extensions {
constructor(description, initializer) {
super();
this.description = description;
this.content = new linq_1.Dictionary();
this.links = new linq_1.Dictionary();
this.headers = new Array();
this.apply(initializer);
}
}
exports.Response = Response;
var ParameterLocation;
(function (ParameterLocation) {
ParameterLocation["Uri"] = "uri";
ParameterLocation["Query"] = "query";
ParameterLocation["Header"] = "header";
ParameterLocation["Cookie"] = "cookie";
ParameterLocation["Path"] = "path";
})(ParameterLocation = exports.ParameterLocation || (exports.ParameterLocation = {}));
var EncodingStyle;
(function (EncodingStyle) {
EncodingStyle["Matrix"] = "matrix";
EncodingStyle["Label"] = "label";
EncodingStyle["Simple"] = "simple";
EncodingStyle["Form"] = "form";
EncodingStyle["SpaceDelimited"] = "spaceDelimited";
EncodingStyle["PipeDelimited"] = "pipeDelimited";
EncodingStyle["DeepObject"] = "deepObject";
})(EncodingStyle = exports.EncodingStyle || (exports.EncodingStyle = {}));
var HttpMethod;
(function (HttpMethod) {
HttpMethod["Get"] = "get";
HttpMethod["Put"] = "put";
HttpMethod["Post"] = "post";
HttpMethod["Delete"] = "delete";
HttpMethod["Options"] = "options";
HttpMethod["Head"] = "head";
HttpMethod["Patch"] = "patch";
HttpMethod["Trace"] = "trace";
})(HttpMethod = exports.HttpMethod || (exports.HttpMethod = {}));
class NewResponse extends extensions_1.Extensions {
constructor(responseCode, description, mimeTypes, objectInitializer) {
super();
this.responseCode = responseCode;
this.description = description;
this.mimeTypes = mimeTypes;
this.details = {
default: {
uid: `response:${uid_1.uid()}`,
isErrorResponse: false,
description: description || (objectInitializer === null || objectInitializer === void 0 ? void 0 : objectInitializer.description) || '',
name: `${responseCode} ${mimeTypes.join(' ')}`,
}
};
this.headers = new Array();
this.apply(objectInitializer);
}
}
exports.NewResponse = NewResponse;
class HttpOperation extends extensions_1.Extensions {
constructor(operationId, baseUrl, path, method, initializer) {
super();
this.baseUrl = baseUrl;
this.path = path;
this.method = method;
this.tags = new Array();
this.parameters = new Array();
this.responses = new linq_1.Dictionary();
this.callbacks = new linq_1.Dictionary();
this.security = new Array();
this.servers = new Array();
this.deprecated = false;
this.details = {
default: {
uid: `http-operation:${uid_1.uid()}`,
description: (initializer === null || initializer === void 0 ? void 0 : initializer.description) || '',
name: operationId,
}
};
this.apply(initializer);
}
}
exports.HttpOperation = HttpOperation;
class HttpOperationParameter extends extensions_1.Extensions {
constructor(name, inWhere, implementation, initializer) {
super();
this.name = name;
this.deprecated = false;
this.required = false;
this.allowEmptyValue = false;
this.in = inWhere;
this.details = {
default: {
uid: `http-parameter:${uid_1.uid()}`,
description: (initializer === null || initializer === void 0 ? void 0 : initializer.description) || '',
location: implementation,
name,
}
};
this.required = inWhere === ParameterLocation.Path;
this.apply(initializer);
}
}
exports.HttpOperationParameter = HttpOperationParameter;
function isHttpOperation(operation) {
if (operation.path) {
return true;
}
return false;
}
exports.isHttpOperation = isHttpOperation;
class Callback {
constructor() {
// unimplemented.
}
}
exports.Callback = Callback;
class HttpComponents extends components_1.Components {
constructor(initializer) {
super();
this.examples = new linq_1.Dictionary();
this.securitySchemes = new linq_1.Dictionary();
this.links = new linq_1.Dictionary();
this.callbacks = new linq_1.Dictionary();
this.apply(initializer);
}
}
exports.HttpComponents = HttpComponents;
//# sourceMappingURL=http-operation.js.map