| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782 |
- "use strict";
- var __defProp = Object.defineProperty;
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
- var __getOwnPropNames = Object.getOwnPropertyNames;
- var __hasOwnProp = Object.prototype.hasOwnProperty;
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
- var __export = (target, all) => {
- for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
- };
- var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
- }
- return to;
- };
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
- // src/index.js
- var index_exports = {};
- __export(index_exports, {
- OAApiKeyLocation: () => OAApiKeyLocation,
- OAComponentsSegment: () => OAComponentsSegment,
- OADataFormat: () => OADataFormat,
- OADataType: () => OADataType,
- OADocumentBuilder: () => OADocumentBuilder,
- OADocumentScope: () => OADocumentScope,
- OAMediaType: () => OAMediaType,
- OAOperationMethod: () => OAOperationMethod,
- OAParameterLocation: () => OAParameterLocation,
- OAParameterStyle: () => OAParameterStyle,
- OASecuritySchemeType: () => OASecuritySchemeType,
- OPENAPI_VERSION: () => OPENAPI_VERSION,
- oaCallbackRef: () => oaCallbackRef,
- oaExampleRef: () => oaExampleRef,
- oaLinkRef: () => oaLinkRef,
- oaParameterRef: () => oaParameterRef,
- oaPathItemRef: () => oaPathItemRef,
- oaRef: () => oaRef,
- oaRequestBodyRef: () => oaRequestBodyRef,
- oaResponseRef: () => oaResponseRef,
- oaSchemaRef: () => oaSchemaRef,
- oaSecuritySchemeRef: () => oaSecuritySchemeRef
- });
- module.exports = __toCommonJS(index_exports);
- // src/constants.js
- var OPENAPI_VERSION = "3.1.0";
- var OAComponentsSegment = {
- SCHEMAS: "schemas",
- RESPONSES: "responses",
- PARAMETERS: "parameters",
- EXAMPLES: "examples",
- REQUEST_BODIES: "requestBodies",
- HEADERS: "headers",
- SECURITY_SCHEMES: "securitySchemes",
- LINKS: "links",
- CALLBACKS: "callbacks",
- PATH_ITEMS: "pathItems"
- };
- // src/utils/oa-ref.js
- var import_js_format = require("@e22m4u/js-format");
- function oaRef(name, segment) {
- if (!name || typeof name !== "string") {
- throw new import_js_format.InvalidArgumentError(
- 'Parameter "name" must be a non-empty String, but %v was given.',
- name
- );
- }
- if (!Object.values(OAComponentsSegment).includes(segment)) {
- throw new import_js_format.InvalidArgumentError(
- 'Parameter "segment" must be one of values: %l, but %v was given.',
- Object.values(OAComponentsSegment),
- segment
- );
- }
- return { $ref: `#/components/${segment}/${name}` };
- }
- __name(oaRef, "oaRef");
- var oaSchemaRef = /* @__PURE__ */ __name((name) => oaRef(name, OAComponentsSegment.SCHEMAS), "oaSchemaRef");
- var oaResponseRef = /* @__PURE__ */ __name((name) => oaRef(name, OAComponentsSegment.RESPONSES), "oaResponseRef");
- var oaParameterRef = /* @__PURE__ */ __name((name) => oaRef(name, OAComponentsSegment.PARAMETERS), "oaParameterRef");
- var oaExampleRef = /* @__PURE__ */ __name((name) => oaRef(name, OAComponentsSegment.EXAMPLES), "oaExampleRef");
- var oaRequestBodyRef = /* @__PURE__ */ __name((name) => oaRef(name, OAComponentsSegment.REQUEST_BODIES), "oaRequestBodyRef");
- var oaSecuritySchemeRef = /* @__PURE__ */ __name((name) => oaRef(name, OAComponentsSegment.SECURITY_SCHEMES), "oaSecuritySchemeRef");
- var oaLinkRef = /* @__PURE__ */ __name((name) => oaRef(name, OAComponentsSegment.LINKS), "oaLinkRef");
- var oaCallbackRef = /* @__PURE__ */ __name((name) => oaRef(name, OAComponentsSegment.CALLBACKS), "oaCallbackRef");
- var oaPathItemRef = /* @__PURE__ */ __name((name) => oaRef(name, OAComponentsSegment.PATH_ITEMS), "oaPathItemRef");
- // src/utils/join-path.js
- function joinPath(...segments) {
- const path = segments.filter((seg) => seg != void 0).map((seg) => String(seg).replace(/(^\/|\/$)/g, "")).filter(Boolean).join("/");
- return "/" + path;
- }
- __name(joinPath, "joinPath");
- // src/oa-document-scope.js
- var import_js_format4 = require("@e22m4u/js-format");
- // src/oa-document-builder.js
- var import_js_format3 = require("@e22m4u/js-format");
- // src/document-specification.js
- var OAOperationMethod = {
- GET: "get",
- PUT: "put",
- POST: "post",
- DELETE: "delete",
- OPTIONS: "options",
- HEAD: "head",
- PATCH: "patch",
- TRACE: "trace"
- };
- var OAParameterLocation = {
- QUERY: "query",
- HEADER: "header",
- PATH: "path",
- COOKIE: "cookie"
- };
- var OAParameterStyle = {
- MATRIX: "matrix",
- LABEL: "label",
- FORM: "form",
- SIMPLE: "simple",
- SPACE_DELIMITED: "spaceDelimited",
- PIPE_DELIMITED: "pipeDelimited",
- DEEP_OBJECT: "deepObject"
- };
- var OADataType = {
- STRING: "string",
- NUMBER: "number",
- INTEGER: "integer",
- BOOLEAN: "boolean",
- OBJECT: "object",
- ARRAY: "array",
- NULL: "null"
- };
- var OADataFormat = {
- INT32: "int32",
- INT64: "int64",
- FLOAT: "float",
- DOUBLE: "double",
- PASSWORD: "password",
- BINARY: "binary"
- };
- var OAMediaType = {
- TEXT_PLAIN: "text/plain",
- TEXT_HTML: "text/html",
- APPLICATION_XML: "application/xml",
- APPLICATION_JSON: "application/json",
- MULTIPART_FORM_DATA: "multipart/form-data"
- };
- var OASecuritySchemeType = {
- API_KEY: "apiKey",
- HTTP: "http",
- MUTUAL_TLS: "mutualTLS",
- OAUTH_2: "oauth2",
- OPEN_ID_CONNECT: "openIdConnect"
- };
- var OAApiKeyLocation = {
- QUERY: "query",
- HEADER: "header",
- COOKIE: "cookie"
- };
- // src/oa-document-builder.js
- var import_js_service = require("@e22m4u/js-service");
- // src/document-validators.js
- var import_js_format2 = require("@e22m4u/js-format");
- function validateShallowOADocumentObject(documentObject) {
- if (!documentObject || typeof documentObject !== "object" || Array.isArray(documentObject)) {
- throw new import_js_format2.InvalidArgumentError(
- "OpenAPI Document Object must be an Object, but %v was given.",
- documentObject
- );
- }
- if (!documentObject.openapi || typeof documentObject.openapi !== "string") {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "openapi" must be a non-empty String, but %v was given.',
- documentObject.openapi
- );
- }
- if (!documentObject.info || typeof documentObject.info !== "object" || Array.isArray(documentObject.info)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "info" must be an Object, but %v was given.',
- documentObject.info
- );
- }
- if (documentObject.jsonSchemaDialect !== void 0) {
- if (!documentObject.jsonSchemaDialect || typeof documentObject.jsonSchemaDialect !== "string") {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "jsonSchemaDialect" must be a non-empty String, but %v was given.',
- documentObject.jsonSchemaDialect
- );
- }
- }
- if (documentObject.servers !== void 0) {
- if (!Array.isArray(documentObject.servers)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "servers" must be an Array, but %v was given.',
- documentObject.servers
- );
- }
- documentObject.servers.forEach((serverObject, index) => {
- if (!serverObject || typeof serverObject !== "object" || Array.isArray(serverObject)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Element "servers[%d]" must be an Object, but %v was given.',
- index,
- serverObject
- );
- }
- });
- }
- if (documentObject.paths !== void 0) {
- if (!documentObject.paths || typeof documentObject.paths !== "object" || Array.isArray(documentObject.paths)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "paths" must be an Object, but %v was given.',
- documentObject.paths
- );
- }
- }
- if (documentObject.webhooks !== void 0) {
- if (!documentObject.webhooks || typeof documentObject.webhooks !== "object" || Array.isArray(documentObject.webhooks)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "webhooks" must be an Object, but %v was given.',
- documentObject.webhooks
- );
- }
- }
- if (documentObject.components !== void 0) {
- if (!documentObject.components || typeof documentObject.components !== "object" || Array.isArray(documentObject.components)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "components" must be an Object, but %v was given.',
- documentObject.components
- );
- }
- }
- if (documentObject.security !== void 0) {
- if (!Array.isArray(documentObject.security)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "security" must be an Array, but %v was given.',
- documentObject.security
- );
- }
- documentObject.security.forEach((securityRequirementObject, index) => {
- if (!securityRequirementObject || typeof securityRequirementObject !== "object" || Array.isArray(securityRequirementObject)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Element "security[%d]" must be an Object, but %v was given.',
- index,
- securityRequirementObject
- );
- }
- });
- }
- if (documentObject.tags !== void 0) {
- if (!Array.isArray(documentObject.tags)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "tags" must be an Array, but %v was given.',
- documentObject.tags
- );
- }
- documentObject.tags.forEach((tagObject, index) => {
- if (!tagObject || typeof tagObject !== "object" || Array.isArray(tagObject)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Element "tags[%d]" must be an Object, but %v was given.',
- index,
- tagObject
- );
- }
- });
- }
- if (documentObject.externalDocs !== void 0) {
- if (!documentObject.externalDocs || typeof documentObject.externalDocs !== "object" || Array.isArray(documentObject.externalDocs)) {
- throw new import_js_format2.InvalidArgumentError(
- 'Property "externalDocs" must be an Object, but %v was given.',
- documentObject.externalDocs
- );
- }
- }
- }
- __name(validateShallowOADocumentObject, "validateShallowOADocumentObject");
- // src/oa-document-builder.js
- var OADocumentBuilder = class extends import_js_service.Service {
- static {
- __name(this, "OADocumentBuilder");
- }
- /**
- * Document.
- *
- * @private
- * @type {object}
- */
- _document = {
- openapi: OPENAPI_VERSION,
- info: {
- title: "API Documentation",
- version: "0.0.1"
- }
- };
- /**
- * Constructor.
- *
- * @param {object} [containerOrDocument]
- * @param {object} [document]
- */
- constructor(containerOrDocument, document) {
- if ((0, import_js_service.isServiceContainer)(containerOrDocument)) {
- super(containerOrDocument);
- } else {
- super();
- document = containerOrDocument;
- }
- if (document !== void 0) {
- if (!document || typeof document !== "object" || Array.isArray(document)) {
- throw new import_js_format3.InvalidArgumentError(
- "OpenAPI Document Object must be an Object, but %v was given.",
- document
- );
- }
- document = structuredClone(document);
- if (!document.openapi) {
- document.openapi = this._document.openapi;
- }
- if (!document.info) {
- document.info = this._document.info;
- }
- if (!document.info || typeof document.info !== "object" || Array.isArray(document.info)) {
- throw new import_js_format3.InvalidArgumentError(
- 'Property "info" must be an Object, but %v was given.',
- document.info
- );
- }
- if (!document.info.title) {
- document.info.title = this._document.info.title;
- }
- if (!document.info.version) {
- document.info.version = this._document.info.version;
- }
- validateShallowOADocumentObject(document);
- this._document = document;
- }
- }
- /**
- * Define component.
- *
- * @param {string} segmentName
- * @param {string} propertyName
- * @param {object} definition
- * @returns {this}
- */
- _defineComponent(segmentName, propertyName, definition) {
- if (!Object.values(OAComponentsSegment).includes(segmentName)) {
- throw new import_js_format3.InvalidArgumentError(
- 'Property "segmentName" must be one of values: %l, but %v was given.',
- Object.values(OAComponentsSegment),
- segmentName
- );
- }
- if (!propertyName || typeof propertyName !== "string") {
- throw new import_js_format3.InvalidArgumentError(
- 'Property "propertyName" must be a non-empty String, but %v was given.',
- propertyName
- );
- }
- if (!definition || typeof definition !== "object" || Array.isArray(definition)) {
- throw new import_js_format3.InvalidArgumentError(
- "Component definition must be an Object, but %v was given.",
- definition
- );
- }
- if (!definition.name || typeof definition.name !== "string") {
- throw new import_js_format3.InvalidArgumentError(
- 'Property "name" must be a non-empty String, but %v was given.',
- definition.name
- );
- }
- const component = definition[propertyName];
- if (!component || typeof component !== "object" || Array.isArray(component)) {
- throw new import_js_format3.InvalidArgumentError(
- "Property %v must be an Object, but %v was given.",
- propertyName,
- component
- );
- }
- if (!this._document.components) {
- this._document.components = {};
- }
- if (!this._document.components[segmentName]) {
- this._document.components[segmentName] = {};
- }
- this._document.components[segmentName][definition.name] = structuredClone(component);
- return this;
- }
- /**
- * Define schema component.
- *
- * @param {object} schemaDef
- * @returns {this}
- */
- defineSchemaComponent(schemaDef) {
- return this._defineComponent(
- OAComponentsSegment.SCHEMAS,
- "schema",
- schemaDef
- );
- }
- /**
- * Define response component.
- *
- * @param {object} responseDef
- * @returns {this}
- */
- defineResponseComponent(responseDef) {
- return this._defineComponent(
- OAComponentsSegment.RESPONSES,
- "response",
- responseDef
- );
- }
- /**
- * Define parameter component.
- *
- * @param {object} parameterDef
- * @returns {this}
- */
- defineParameterComponent(parameterDef) {
- return this._defineComponent(
- OAComponentsSegment.PARAMETERS,
- "parameter",
- parameterDef
- );
- }
- /**
- * Define example component.
- *
- * @param {object} exampleDef
- * @returns {this}
- */
- defineExampleComponent(exampleDef) {
- return this._defineComponent(
- OAComponentsSegment.EXAMPLES,
- "example",
- exampleDef
- );
- }
- /**
- * Define request body component.
- *
- * @param {object} requestBodyDef
- * @returns {this}
- */
- defineRequestBodyComponent(requestBodyDef) {
- return this._defineComponent(
- OAComponentsSegment.REQUEST_BODIES,
- "requestBody",
- requestBodyDef
- );
- }
- /**
- * Define header component.
- *
- * @param {object} headerDef
- * @returns {this}
- */
- defineHeaderComponent(headerDef) {
- return this._defineComponent(
- OAComponentsSegment.HEADERS,
- "header",
- headerDef
- );
- }
- /**
- * Define security scheme component.
- *
- * @param {object} securitySchemeDef
- * @returns {this}
- */
- defineSecuritySchemeComponent(securitySchemeDef) {
- return this._defineComponent(
- OAComponentsSegment.SECURITY_SCHEMES,
- "securityScheme",
- securitySchemeDef
- );
- }
- /**
- * Define link component.
- *
- * @param {object} linkDef
- * @returns {this}
- */
- defineLinkComponent(linkDef) {
- return this._defineComponent(
- OAComponentsSegment.LINKS,
- "link",
- linkDef
- );
- }
- /**
- * Define callback component.
- *
- * @param {object} callbackDef
- * @returns {this}
- */
- defineCallbackComponent(callbackDef) {
- return this._defineComponent(
- OAComponentsSegment.CALLBACKS,
- "callback",
- callbackDef
- );
- }
- /**
- * Define path item component.
- *
- * @param {object} pathItemDef
- * @returns {this}
- */
- definePathItemComponent(pathItemDef) {
- return this._defineComponent(
- OAComponentsSegment.PATH_ITEMS,
- "pathItem",
- pathItemDef
- );
- }
- /**
- * Define operation.
- *
- * @param {object} operationDef
- */
- defineOperation(operationDef) {
- if (!operationDef || typeof operationDef !== "object" || Array.isArray(operationDef)) {
- throw new import_js_format3.InvalidArgumentError(
- "Operation Definition must be an Object, but %v was given.",
- operationDef
- );
- }
- if (!operationDef.path || typeof operationDef.path !== "string") {
- throw new import_js_format3.InvalidArgumentError(
- 'Property "path" must be a non-empty String, but %v was given.',
- operationDef.path
- );
- }
- if (operationDef.path[0] !== "/") {
- throw new import_js_format3.InvalidArgumentError(
- 'Property "path" must start with forward slash "/", but %v was given.',
- operationDef.path
- );
- }
- if (!operationDef.method || typeof operationDef.method !== "string") {
- throw new import_js_format3.InvalidArgumentError(
- 'Property "method" must be a non-empty String, but %v was given.',
- operationDef.method
- );
- }
- if (!Object.values(OAOperationMethod).includes(operationDef.method)) {
- throw new import_js_format3.InvalidArgumentError(
- 'Property "method" must be one of values: %l, but %v was given.',
- Object.values(OAOperationMethod)
- );
- }
- if (!operationDef.operation || typeof operationDef.operation !== "object" || Array.isArray(operationDef.operation)) {
- throw new import_js_format3.InvalidArgumentError(
- 'Property "operation" must be an Object, but %v was given.',
- operationDef.operation
- );
- }
- if (!this._document.paths) {
- this._document.paths = {};
- }
- if (!this._document.paths[operationDef.path]) {
- this._document.paths[operationDef.path] = {};
- }
- this._document.paths[operationDef.path][operationDef.method] = structuredClone(operationDef.operation);
- }
- /**
- * Create scope.
- *
- * @param {object} [options]
- * @returns {OADocumentScope}
- */
- createScope(options) {
- return new OADocumentScope(this, options);
- }
- /**
- * Build.
- *
- * @returns {object}
- */
- build() {
- return structuredClone(this._document);
- }
- /**
- * Build JSON.
- *
- * @param {string|number} [space]
- * @returns {string}
- */
- buildJson(space = 0) {
- return JSON.stringify(this._document, null, space);
- }
- };
- // src/oa-document-scope.js
- var OADocumentScope = class _OADocumentScope {
- static {
- __name(this, "OADocumentScope");
- }
- /**
- * @param {object} rootBuilder
- * @param {object} [options]
- */
- constructor(rootBuilder, options = {}) {
- if (!(rootBuilder instanceof OADocumentBuilder)) {
- throw new import_js_format4.InvalidArgumentError(
- 'Parameter "rootBuilder" must be an instance of OADocumentBuilder, but %v was given.',
- rootBuilder
- );
- }
- if (!options || typeof options !== "object" || Array.isArray(options)) {
- throw new import_js_format4.InvalidArgumentError(
- 'Parameter "options" must be an Object, but %v was given.',
- options
- );
- }
- if (options.pathPrefix !== void 0) {
- if (!options.pathPrefix || typeof options.pathPrefix !== "string") {
- throw new import_js_format4.InvalidArgumentError(
- 'Parameter "pathPrefix" must be a non-empty String, but %v was given.',
- options.pathPrefix
- );
- }
- }
- if (options.tags !== void 0) {
- if (!Array.isArray(options.tags)) {
- throw new import_js_format4.InvalidArgumentError(
- 'Parameter "tags" must be an Array, but %v was given.',
- options.tags
- );
- }
- options.tags.forEach((tag, index) => {
- if (!tag || typeof tag !== "string") {
- throw new import_js_format4.InvalidArgumentError(
- 'Element "tags[%d]" must be a non-empty String, but %v was given.',
- index,
- tag
- );
- }
- });
- }
- this.rootBuilder = rootBuilder;
- this.pathPrefix = options.pathPrefix || "/";
- this.tags = options.tags || [];
- }
- /**
- * Define operation.
- *
- * @param {object} operationDef
- * @returns {this}
- */
- defineOperation(operationDef) {
- if (!operationDef || typeof operationDef !== "object" || Array.isArray(operationDef)) {
- throw new import_js_format4.InvalidArgumentError(
- "Operation Definition must be an Object, but %v was given.",
- operationDef
- );
- }
- if (!operationDef.path || typeof operationDef.path !== "string") {
- throw new import_js_format4.InvalidArgumentError(
- 'Property "path" must be a non-empty String, but %v was given.',
- operationDef.path
- );
- }
- if (operationDef.path[0] !== "/") {
- throw new import_js_format4.InvalidArgumentError(
- 'Property "path" must start with forward slash "/", but %v was given.',
- operationDef.path
- );
- }
- if (!operationDef.method || typeof operationDef.method !== "string") {
- throw new import_js_format4.InvalidArgumentError(
- 'Property "method" must be a non-empty String, but %v was given.',
- operationDef.method
- );
- }
- if (!Object.values(OAOperationMethod).includes(operationDef.method)) {
- throw new import_js_format4.InvalidArgumentError(
- 'Property "method" must be one of values: %l, but %v was given.',
- Object.values(OAOperationMethod)
- );
- }
- if (!operationDef.operation || typeof operationDef.operation !== "object" || Array.isArray(operationDef.operation)) {
- throw new import_js_format4.InvalidArgumentError(
- 'Property "operation" must be an Object, but %v was given.',
- operationDef.operation
- );
- }
- const fullPath = joinPath(this.pathPrefix, operationDef.path);
- const operation = structuredClone(operationDef.operation);
- if (this.tags.length > 0) {
- operation.tags = [...this.tags, ...operation.tags || []];
- operation.tags = [...new Set(operation.tags)];
- }
- this.rootBuilder.defineOperation({
- ...operationDef,
- path: fullPath,
- operation
- });
- return this;
- }
- /**
- * Create scope.
- *
- * @param {object} [options]
- * @returns {OADocumentScope}
- */
- createScope(options = {}) {
- if (!options || typeof options !== "object" || Array.isArray(options)) {
- throw new import_js_format4.InvalidArgumentError(
- 'Parameter "options" must be an Object, but %v was given.',
- options
- );
- }
- if (options.pathPrefix !== void 0) {
- if (!options.pathPrefix || typeof options.pathPrefix !== "string") {
- throw new import_js_format4.InvalidArgumentError(
- 'Parameter "pathPrefix" must be a non-empty String, but %v was given.',
- options.pathPrefix
- );
- }
- }
- if (options.tags !== void 0) {
- if (!Array.isArray(options.tags)) {
- throw new import_js_format4.InvalidArgumentError(
- 'Parameter "tags" must be an Array, but %v was given.',
- options.tags
- );
- }
- options.tags.forEach((tag, index) => {
- if (!tag || typeof tag !== "string") {
- throw new import_js_format4.InvalidArgumentError(
- 'Element "tags[%d]" must be a non-empty String, but %v was given.',
- index,
- tag
- );
- }
- });
- }
- return new _OADocumentScope(this.rootBuilder, {
- pathPrefix: joinPath(this.pathPrefix, options.pathPrefix),
- tags: [...this.tags, ...options.tags || []]
- });
- }
- };
- // Annotate the CommonJS export names for ESM import in node:
- 0 && (module.exports = {
- OAApiKeyLocation,
- OAComponentsSegment,
- OADataFormat,
- OADataType,
- OADocumentBuilder,
- OADocumentScope,
- OAMediaType,
- OAOperationMethod,
- OAParameterLocation,
- OAParameterStyle,
- OASecuritySchemeType,
- OPENAPI_VERSION,
- oaCallbackRef,
- oaExampleRef,
- oaLinkRef,
- oaParameterRef,
- oaPathItemRef,
- oaRef,
- oaRequestBodyRef,
- oaResponseRef,
- oaSchemaRef,
- oaSecuritySchemeRef
- });
|