fastman
Version:
快速api测试及文档生成
139 lines • 4.82 kB
JavaScript
;
/**
* @license
* Copyright 2017 Red Hat
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var __modelIdCounter = 0;
/**
* Base class for all OAS nodes. Contains common fields and methods across all
* nodes of all versions of the OpenAPI Specification.
*/
var OasNode = /** @class */ (function () {
function OasNode() {
this._modelId = __modelIdCounter++;
this._attributes = new OasNodeAttributes();
this._validationProblems = {}; // Really a map of string(errorCode)->OasValidationProblem
}
/**
* Gets the owner document.
* @return {OasDocument}
*/
OasNode.prototype.ownerDocument = function () {
return this._ownerDocument;
};
/**
* Gets the parent.
* @return {OasNode}
*/
OasNode.prototype.parent = function () {
return this._parent;
};
/**
* Gets the model's unique ID.
* @return {number}
*/
OasNode.prototype.modelId = function () {
return this._modelId;
};
/**
* Gets or sets a node attribute. When setting the attribute, the previous value
* will be returned. Otherwise the current value is returned.
* @param name
* @param value
* @return {any}
*/
OasNode.prototype.n_attribute = function (name, value) {
if (value === undefined) {
return this._attributes[name];
}
else {
var pvalue = this._attributes[name];
this._attributes[name] = value;
return pvalue;
}
};
OasNode.prototype.validationProblems = function () {
var problems = [];
for (var _i = 0, _a = this._validationProblems; _i < _a.length; _i++) {
var problem = _a[_i];
problems.push(problem);
}
return problems;
};
OasNode.prototype.validationProblemCodes = function () {
var codes = [];
for (var code in this._validationProblems) {
codes.push(code);
}
return codes;
};
OasNode.prototype.validationProblem = function (code) {
return this._validationProblems[code];
};
OasNode.prototype.addValidationProblem = function (errorCode, nodePath, message) {
var problem = new OasValidationProblem(errorCode, nodePath, message);
problem._ownerDocument = this._ownerDocument;
problem._parent = this;
this._validationProblems[errorCode] = problem;
return problem;
};
OasNode.prototype.clearValidationProblems = function () {
this._validationProblems = {};
};
return OasNode;
}());
exports.OasNode = OasNode;
/**
* Represents a single validation error.
*/
var OasValidationProblem = /** @class */ (function (_super) {
__extends(OasValidationProblem, _super);
/**
* Constructor.
* @param {string} errorCode
* @param {OasNodePath} nodePath
* @param {string} message
*/
function OasValidationProblem(errorCode, nodePath, message) {
var _this = _super.call(this) || this;
_this.errorCode = errorCode;
_this.nodePath = nodePath;
_this.message = message;
return _this;
}
OasValidationProblem.prototype.accept = function (visitor) {
visitor.visitValidationProblem(this);
};
return OasValidationProblem;
}(OasNode));
exports.OasValidationProblem = OasValidationProblem;
var OasNodeAttributes = /** @class */ (function () {
function OasNodeAttributes() {
}
return OasNodeAttributes;
}());
exports.OasNodeAttributes = OasNodeAttributes;
//# sourceMappingURL=node.model.js.map