diff --git a/README.md b/README.md index 7102a4abdd..948a734d28 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ You can install ApiDOM packages using [npm CLI](https://docs.npmjs.com/cli): $ npm install @swagger-api/apidom-parser-adapter-asyncapi-json-2 $ npm install @swagger-api/apidom-parser-adapter-asyncapi-yaml-2 $ npm install @swagger-api/apidom-parser-adapter-json + $ npm install @swagger-api/apidom-parser-adapter-openapi-json-2 $ npm install @swagger-api/apidom-parser-adapter-openapi-json-3-0 $ npm install @swagger-api/apidom-parser-adapter-openapi-json-3-1 $ npm install @swagger-api/apidom-parser-adapter-openapi-yaml-3-0 diff --git a/package-lock.json b/package-lock.json index cc258b7df2..31543e3107 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6671,6 +6671,10 @@ "resolved": "packages/apidom-parser-adapter-json", "link": true }, + "node_modules/@swagger-api/apidom-parser-adapter-openapi-json-2": { + "resolved": "packages/apidom-parser-adapter-openapi-json-2", + "link": true + }, "node_modules/@swagger-api/apidom-parser-adapter-openapi-json-3-0": { "resolved": "packages/apidom-parser-adapter-openapi-json-3-0", "link": true @@ -32520,6 +32524,19 @@ "tree-sitter-cli": "=0.20.4" } }, + "packages/apidom-parser-adapter-openapi-json-2": { + "version": "0.80.0", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime-corejs3": "^7.20.7", + "@swagger-api/apidom-core": "^0.80.0", + "@swagger-api/apidom-ns-openapi-2": "^0.80.0", + "@swagger-api/apidom-parser-adapter-json": "^0.80.0", + "@types/ramda": "~0.29.6", + "ramda": "~0.29.0", + "ramda-adjunct": "^4.0.0" + } + }, "packages/apidom-parser-adapter-openapi-json-3-0": { "name": "@swagger-api/apidom-parser-adapter-openapi-json-3-0", "version": "0.80.0", diff --git a/package.json b/package.json index 7a4b094ff6..b7809ec45f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "clean": "lerna run clean", "test": "lerna run test", "link": "npm link --workspaces", - "unlink": "npm unlink --global @swagger-api/apidom-ast @swagger-api/apidom-core @swagger-api/apidom-error @swagger-api/apidom-json-path @swagger-api/apidom-json-pointer @swagger-api/apidom-json-pointer-relative @swagger-api/apidom-parser-adapter-json @swagger-api/apidom-ns-api-design-systems @swagger-api/apidom-ns-asyncapi-2 @swagger-api/apidom-ns-json-schema-draft-4 @swagger-api/apidom-ns-json-schema-draft-6 @swagger-api/apidom-ns-json-schema-draft-7 @swagger-api/apidom-ns-openapi-2 @swagger-api/apidom-ns-openapi-3-0 @swagger-api/apidom-ns-openapi-3-1 @swagger-api/apidom-parser-adapter-yaml-1-2 @swagger-api/apidom-parser-adapter-asyncapi-yaml-2 @swagger-api/apidom-parser-adapter-openapi-yaml-3-0 @swagger-api/apidom-parser-adapter-openapi-yaml-3-1 @swagger-api/apidom-parser @swagger-api/apidom-parser-adapter-api-design-systems-json @swagger-api/apidom-parser-adapter-api-design-systems-yaml @swagger-api/apidom-parser-adapter-asyncapi-json-2 @swagger-api/apidom-ls @swagger-api/apidom-reference @swagger-api/apidom-parser-adapter-openapi-json-3-0 @swagger-api/apidom-parser-adapter-openapi-json-3-1 @swagger-api/apidom-playground", + "unlink": "npm unlink --global @swagger-api/apidom-ast @swagger-api/apidom-core @swagger-api/apidom-error @swagger-api/apidom-json-path @swagger-api/apidom-json-pointer @swagger-api/apidom-json-pointer-relative @swagger-api/apidom-parser-adapter-json @swagger-api/apidom-ns-api-design-systems @swagger-api/apidom-ns-asyncapi-2 @swagger-api/apidom-ns-json-schema-draft-4 @swagger-api/apidom-ns-json-schema-draft-6 @swagger-api/apidom-ns-json-schema-draft-7 @swagger-api/apidom-ns-openapi-2 @swagger-api/apidom-ns-openapi-3-0 @swagger-api/apidom-ns-openapi-3-1 @swagger-api/apidom-parser-adapter-yaml-1-2 @swagger-api/apidom-parser-adapter-asyncapi-yaml-2 @swagger-api/apidom-parser-adapter-openapi-yaml-3-0 @swagger-api/apidom-parser-adapter-openapi-yaml-3-1 @swagger-api/apidom-parser @swagger-api/apidom-parser-adapter-api-design-systems-json @swagger-api/apidom-parser-adapter-api-design-systems-yaml @swagger-api/apidom-parser-adapter-asyncapi-json-2 @swagger-api/apidom-ls @swagger-api/apidom-reference @swagger-api/apidom-parser-adapter-openapi-json-2 @swagger-api/apidom-parser-adapter-openapi-json-3-0 @swagger-api/apidom-parser-adapter-openapi-json-3-1 @swagger-api/apidom-playground", "prepare": "chmod +x ./node_modules/husky/lib/bin.js && husky install" }, "repository": { diff --git a/packages/apidom-ns-openapi-2/README.md b/packages/apidom-ns-openapi-2/README.md index 05bc29a120..a8bf616d73 100644 --- a/packages/apidom-ns-openapi-2/README.md +++ b/packages/apidom-ns-openapi-2/README.md @@ -12,9 +12,9 @@ You can install this package via [npm CLI](https://docs.npmjs.com/cli) by runnin $ npm install @swagger-api/apidom-ns-openapi-2 ``` -## OpenApi 2.0 namespace +## OpenAPI 2.0 namespace -OpenApi 2.0 namespace consists of [number of elements](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-2/src/elements) implemented on top +OpenAPI 2.0 namespace consists of [number of elements](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-2/src/elements) implemented on top of [primitive ones](https://github.com/refractproject/minim/tree/master/lib/primitives). ```js diff --git a/packages/apidom-ns-openapi-3-0/README.md b/packages/apidom-ns-openapi-3-0/README.md index ee468b198c..f74427686f 100644 --- a/packages/apidom-ns-openapi-3-0/README.md +++ b/packages/apidom-ns-openapi-3-0/README.md @@ -15,9 +15,9 @@ You can install this package via [npm CLI](https://docs.npmjs.com/cli) by runnin $ npm install @swagger-api/apidom-ns-openapi-3-0 ``` -## OpenApi 3.0.x namespace +## OpenAPI 3.0.x namespace -OpenApi 3.0.x namespace consists of [number of elements](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0/src/elements) implemented on top +OpenAPI 3.0.x namespace consists of [number of elements](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0/src/elements) implemented on top of [primitive ones](https://github.com/refractproject/minim/tree/master/lib/primitives). ```js diff --git a/packages/apidom-ns-openapi-3-1/README.md b/packages/apidom-ns-openapi-3-1/README.md index 7f64d31a2c..c28fc0d5ec 100644 --- a/packages/apidom-ns-openapi-3-1/README.md +++ b/packages/apidom-ns-openapi-3-1/README.md @@ -10,9 +10,9 @@ You can install this package via [npm CLI](https://docs.npmjs.com/cli) by runnin $ npm install @swagger-api/apidom-ns-openapi-3-1 ``` -## OpenApi 3.1.0 namespace +## OpenAPI 3.1.0 namespace -OpenApi 3.1.0 namespace consists of [number of elements](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1/src/elements) implemented on top +OpenAPI 3.1.0 namespace consists of [number of elements](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1/src/elements) implemented on top of [primitive ones](https://github.com/refractproject/minim/tree/master/lib/primitives). ```js diff --git a/packages/apidom-parser-adapter-openapi-json-2/.eslintignore b/packages/apidom-parser-adapter-openapi-json-2/.eslintignore new file mode 100644 index 0000000000..856320e627 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/.eslintignore @@ -0,0 +1,8 @@ +/dist +/es +/cjs +/types +/config +/.nyc_output +/node_modules +/**/*.js diff --git a/packages/apidom-parser-adapter-openapi-json-2/.gitignore b/packages/apidom-parser-adapter-openapi-json-2/.gitignore new file mode 100644 index 0000000000..64c35e6d3a --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/.gitignore @@ -0,0 +1,6 @@ +/dist +/es +/cjs +/types +/NOTICE +/swagger-api-apidom-parser-adapter-openapi-json-2-*.tgz diff --git a/packages/apidom-parser-adapter-openapi-json-2/.mocharc.json b/packages/apidom-parser-adapter-openapi-json-2/.mocharc.json new file mode 100644 index 0000000000..e923c24114 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/.mocharc.json @@ -0,0 +1,5 @@ +{ + "recursive": true, + "spec": "test/**/*.ts", + "file": ["test/mocha-bootstrap.cjs"] +} diff --git a/packages/apidom-parser-adapter-openapi-json-2/.npmrc b/packages/apidom-parser-adapter-openapi-json-2/.npmrc new file mode 100644 index 0000000000..4b82d2e7bb --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/.npmrc @@ -0,0 +1,2 @@ +save-prefix="=" +save=false diff --git a/packages/apidom-parser-adapter-openapi-json-2/README.md b/packages/apidom-parser-adapter-openapi-json-2/README.md new file mode 100644 index 0000000000..1e86ab9adc --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/README.md @@ -0,0 +1,86 @@ +# @swagger-api/apidom-parser-adapter-openapi-json-2 + +`@swagger-api/apidom-parser-adapter-openapi-json-2` is a parser adapter for the [OpenAPI 2.0 specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md) in [JSON format](https://www.json.org/json-en.html). +Under the hood this adapter uses [apidom-parser-adapter-json](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-json) +to parse a source string into generic ApiDOM in [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace) +which is then refracted with [OpenAPI 2.0 Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-2#refractors). + +## Installation + +After [prerequisites](https://github.com/swagger-api/apidom/blob/main/README.md#prerequisites) for installing this package are satisfied, you can install it +via [npm CLI](https://docs.npmjs.com/cli) by running the following command: + +```sh + $ npm install @swagger-api/apidom-parser-adapter-openapi-json-2 +``` + +## Parser adapter API + +This parser adapter is fully compatible with parser adapter interface required by [@swagger-api/apidom-parser](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser#mounting-parser-adapters) +and implements all required properties. + +### mediaTypes + +Defines list of media types that this parser adapter recognizes. + +```js +[ + 'application/vnd.oai.openapi;version=2.0', + 'application/vnd.oai.openapi+json;version=2.0', +] +``` + +### detect + +[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-openapi-json-2/src/adapter.ts#L11) is based on a regular expression matching required OpenAPI 2.0 specification symbols in JSON format. + +### namespace + +This adapter exposes an instance of [OpenAPI 2.0 ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-2#openapi-20-namespace). + +### parse + +`parse` function consumes various options as a second argument. Here is a list of these options: + +Option | Type | Default | Description +--- | --- | --- | --- +`specObj` | `Object` | [Specification Object](https://github.com/swagger-api/apidom/blob/main/packages/apidom-ns-openapi-2/src/refractor/specification.ts) | This specification object drives the JSON AST transformation to OpenAPI 2.0 ApiDOM namespace. +`sourceMap` | `Boolean` | `false` | Indicate whether to generate source maps. +`refractorOpts` | `Object` | `{}` | Refractor options are [passed to refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-2#refractor-plugins) during refracting phase. + +All unrecognized arbitrary options will be ignored. + +## Usage + +This parser adapter can be used directly or indirectly via [@swagger-api/apidom-parser](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser). + +### Direct usage + +During direct usage you don't need to provide `mediaType` as the `parse` function is already pre-bound +with [supported media types](#mediatypes). + +```js +import { parse, detect } from '@swagger-api/apidom-parser-adapter-openapi-json-2'; + +// detecting +await detect('{"swagger": "2.0"}'); // => true +await detect('test'); // => false + +// parsing +const parseResult = await parse('{"swagger": "2.0"}', { sourceMap: true }); +``` + +### Indirect usage + +You can omit the `mediaType` option here, but please read [Word on detect vs mediaTypes](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser#word-on-detect-vs-mediatypes) before you do so. + +```js +import ApiDOMParser from '@swagger-api/apidom-parser'; +import * as openApiJsonAdapter from '@swagger-api/apidom-parser-adapter-openapi-json-2'; + +const parser = ApiDOMParser(); + +parser.use(openApiJsonAdapter); + +const parseResult = await parser.parse('{"swagger": "2.0"}', { mediaType: openApiJsonAdapter.mediaTypes.latest('json') }); +``` diff --git a/packages/apidom-parser-adapter-openapi-json-2/config/rollup/types.dist.js b/packages/apidom-parser-adapter-openapi-json-2/config/rollup/types.dist.js new file mode 100644 index 0000000000..6ecc45f65c --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/config/rollup/types.dist.js @@ -0,0 +1,11 @@ +import dts from 'rollup-plugin-dts'; + +const config = [ + { + input: './types/adapter.d.ts', + output: [{ file: 'types/dist.d.ts', format: 'es' }], + plugins: [dts()], + }, +]; + +export default config; diff --git a/packages/apidom-parser-adapter-openapi-json-2/config/webpack/browser.config.js b/packages/apidom-parser-adapter-openapi-json-2/config/webpack/browser.config.js new file mode 100644 index 0000000000..0bee6b3694 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/config/webpack/browser.config.js @@ -0,0 +1,92 @@ +import path from 'node:path'; +import { nonMinimizeTrait, minimizeTrait } from './traits.config.js'; + +const browser = { + mode: 'production', + entry: ['./src/adapter.ts'], + target: 'web', + performance: { + maxEntrypointSize: 1800000, + maxAssetSize: 1800000, + }, + output: { + path: path.resolve('./dist'), + filename: 'apidom-parser-adapter-openapi-json-2.browser.js', + libraryTarget: 'umd', + library: 'apidomParserAdapterOpenApiJson2', + }, + resolve: { + extensions: ['.ts', '.mjs', '.js', '.json'], + fallback: { + fs: false, + path: false, + }, + }, + module: { + rules: [ + { + test: /\.wasm$/, + loader: 'file-loader', + type: 'javascript/auto', + }, + { + test: /\.(ts|js)?$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + babelrc: true, + rootMode: 'upward', + }, + }, + }, + ], + }, + ...nonMinimizeTrait, +}; + +const browserMin = { + mode: 'production', + entry: ['./src/adapter.ts'], + target: 'web', + performance: { + maxEntrypointSize: 280000, + maxAssetSize: 280000, + }, + output: { + path: path.resolve('./dist'), + filename: 'apidom-parser-adapter-openapi-json-2.browser.min.js', + libraryTarget: 'umd', + library: 'apidomParserAdapterOpenApiJson2', + }, + resolve: { + extensions: ['.ts', '.mjs', '.js', '.json'], + fallback: { + fs: false, + path: false, + }, + }, + module: { + rules: [ + { + test: /\.wasm$/, + loader: 'file-loader', + type: 'javascript/auto', + }, + { + test: /\.(ts|js)?$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + babelrc: true, + rootMode: 'upward', + }, + }, + }, + ], + }, + ...minimizeTrait, +}; + +export default [browser, browserMin]; diff --git a/packages/apidom-parser-adapter-openapi-json-2/config/webpack/traits.config.js b/packages/apidom-parser-adapter-openapi-json-2/config/webpack/traits.config.js new file mode 100644 index 0000000000..9043521175 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/config/webpack/traits.config.js @@ -0,0 +1,32 @@ +import webpack from 'webpack'; +import TerserPlugin from 'terser-webpack-plugin'; + +export const nonMinimizeTrait = { + optimization: { + minimize: false, + usedExports: false, + concatenateModules: false, + }, +}; + +export const minimizeTrait = { + plugins: [ + new webpack.LoaderOptionsPlugin({ + minimize: true, + }), + ], + optimization: { + minimizer: [ + new TerserPlugin({ + terserOptions: { + compress: { + warnings: false, + }, + output: { + comments: false, + }, + }, + }), + ], + }, +}; diff --git a/packages/apidom-parser-adapter-openapi-json-2/declaration.tsconfig.json b/packages/apidom-parser-adapter-openapi-json-2/declaration.tsconfig.json new file mode 100644 index 0000000000..5697fa3e89 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/declaration.tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "exclude": [ + "test/**/*" + ], + "compilerOptions": { + "declaration": true, + "declarationDir": "types", + "noEmit": false, + "emitDeclarationOnly": true + } +} diff --git a/packages/apidom-parser-adapter-openapi-json-2/package.json b/packages/apidom-parser-adapter-openapi-json-2/package.json new file mode 100644 index 0000000000..56c30f2b47 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/package.json @@ -0,0 +1,58 @@ +{ + "name": "@swagger-api/apidom-parser-adapter-openapi-json-2", + "version": "0.80.0", + "description": "Parser adapter for parsing JSON documents into OpenAPI 2.0 namespace.", + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org" + }, + "type": "module", + "sideEffects": false, + "unpkg": "./dist/apidom-parser-apdater-openapi-json-2.browser.min.js", + "main": "./cjs/adapter.cjs", + "exports": { + "types": "./types/dist.d.ts", + "import": "./es/adapter.mjs", + "require": "./cjs/adapter.cjs" + }, + "types": "./types/dist.d.ts", + "scripts": { + "build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser", + "build:es": "cross-env BABEL_ENV=es babel src --out-dir es --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'", + "build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'", + "build:umd:browser": "cross-env BABEL_ENV=browser webpack --config config/webpack/browser.config.js --progress", + "lint": "eslint ./", + "lint:fix": "eslint ./ --fix", + "clean": "rimraf ./es ./cjs ./dist ./types", + "typescript:check-types": "tsc --noEmit", + "typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js", + "test": "cross-env NODE_ENV=test BABEL_ENV=cjs mocha", + "prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .", + "postpack": "rimraf NOTICE LICENSES" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/swagger-api/apidom.git" + }, + "author": "Vladimir Gorej", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime-corejs3": "^7.20.7", + "@swagger-api/apidom-core": "^0.80.0", + "@swagger-api/apidom-ns-openapi-2": "^0.80.0", + "@swagger-api/apidom-parser-adapter-json": "^0.80.0", + "@types/ramda": "~0.29.6", + "ramda": "~0.29.0", + "ramda-adjunct": "^4.0.0" + }, + "files": [ + "cjs/", + "dist/", + "es/", + "types/dist.d.ts", + "LICENSES", + "NOTICE", + "README.md", + "CHANGELOG.md" + ] +} diff --git a/packages/apidom-parser-adapter-openapi-json-2/src/adapter.ts b/packages/apidom-parser-adapter-openapi-json-2/src/adapter.ts new file mode 100644 index 0000000000..00345fda11 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/src/adapter.ts @@ -0,0 +1,32 @@ +import { propOr, omit } from 'ramda'; +import { isNotUndefined } from 'ramda-adjunct'; +import { ParseResultElement, createNamespace } from '@swagger-api/apidom-core'; +import { parse as parseJSON, detect as detectJSON } from '@swagger-api/apidom-parser-adapter-json'; +import openApiNamespace, { SwaggerElement } from '@swagger-api/apidom-ns-openapi-2'; + +export { default as mediaTypes } from './media-types'; + +export const detectionRegExp = /"swagger"\s*:\s*"(?2\.0)"/; + +export const detect = async (source: string): Promise => + detectionRegExp.test(source) && (await detectJSON(source)); + +export const parse = async ( + source: string, + options: Record = {}, +): Promise => { + const refractorOpts: Record = propOr({}, 'refractorOpts', options); + const parserOpts = omit(['refractorOpts'], options); + const parseResultElement = await parseJSON(source, parserOpts); + const { result } = parseResultElement; + + if (isNotUndefined(result)) { + const swaggerElement = SwaggerElement.refract(result, refractorOpts); + swaggerElement.classes.push('result'); + parseResultElement.replaceResult(swaggerElement); + } + + return parseResultElement; +}; + +export const namespace = createNamespace(openApiNamespace); diff --git a/packages/apidom-parser-adapter-openapi-json-2/src/media-types.ts b/packages/apidom-parser-adapter-openapi-json-2/src/media-types.ts new file mode 100644 index 0000000000..ffe7b0334a --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/src/media-types.ts @@ -0,0 +1,8 @@ +import { mediaTypes, OpenAPIMediaTypes } from '@swagger-api/apidom-ns-openapi-2'; + +const jsonMediaTypes = new OpenAPIMediaTypes( + ...mediaTypes.filterByFormat('generic'), + ...mediaTypes.filterByFormat('json'), +); + +export default jsonMediaTypes; diff --git a/packages/apidom-parser-adapter-openapi-json-2/test/.eslintrc b/packages/apidom-parser-adapter-openapi-json-2/test/.eslintrc new file mode 100644 index 0000000000..85759a803c --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/test/.eslintrc @@ -0,0 +1,38 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "document": true + }, + "plugins": [ + "mocha" + ], + "rules": { + "no-void": 0, + "func-names": 0, + "prefer-arrow-callback": 0, + "no-array-constructor": 0, + "prefer-rest-params": 0, + "no-new-wrappers": 0, + "mocha/no-skipped-tests": 2, + "mocha/handle-done-callback": 2, + "mocha/valid-suite-description": 2, + "mocha/no-mocha-arrows": 2, + "mocha/no-hooks-for-single-case": 2, + "mocha/no-sibling-hooks": 2, + "mocha/no-top-level-hooks": 2, + "mocha/no-identical-title": 2, + "mocha/no-nested-tests": 2, + "mocha/no-exclusive-tests": 2 + }, + "overrides": [{ + "files": ["mocha-bootstrap.cjs"], + "parserOptions": { + "sourceType": "script" + }, + "rules": { + "@typescript-eslint/no-var-requires": 0 + } + }] +} diff --git a/packages/apidom-parser-adapter-openapi-json-2/test/__snapshots__/adapter.ts.snap b/packages/apidom-parser-adapter-openapi-json-2/test/__snapshots__/adapter.ts.snap new file mode 100644 index 0000000000..bbc489be5d --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/test/__snapshots__/adapter.ts.snap @@ -0,0 +1,1961 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`adapter should parse 1`] = ` +(ParseResultElement + (SwaggerElement + (MemberElement + (StringElement) + (SwaggerVersionElement)) + (MemberElement + (StringElement) + (InfoElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ContactElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (LicenseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (TagElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ExternalDocumentationElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))))) + (TagElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))) + (TagElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ExternalDocumentationElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))))))) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (PathsElement + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement))))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement)))))))) + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement))))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ItemsElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement)))))))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ItemsElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement)))))))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (BooleanElement)))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement))))))) + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))) + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))) + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement)))))))) + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))) + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))) + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))) + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement)))))))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement)) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement))))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (NumberElement)) + (MemberElement + (StringElement) + (NumberElement)) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))) + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (NumberElement)) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement))))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement))))))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement))))))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))) + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (HeadersElement + (MemberElement + (StringElement) + (HeaderElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (HeaderElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))))))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement)) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (PathItemElement + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))) + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))) + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement))))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))) + (MemberElement + (StringElement) + (OperationElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ArrayElement + (ParameterElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)) + (MemberElement + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (ResponsesElement + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (ResponseElement + (MemberElement + (StringElement) + (StringElement)))))))))))) + (MemberElement + (StringElement) + (SecurityDefinitionsElement + (MemberElement + (StringElement) + (SecuritySchemeElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ScopesElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (SecuritySchemeElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (DefinitionsElement + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ObjectElement + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement) + (StringElement))))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)))))) + (MemberElement + (StringElement) + (XmlElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ObjectElement + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (XmlElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ObjectElement + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (XmlElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ObjectElement + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (XmlElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (ObjectElement + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (XmlElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (XmlElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (BooleanElement)))) + (MemberElement + (StringElement) + (JSONReferenceElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement) + (StringElement))))))) + (MemberElement + (StringElement) + (XmlElement + (MemberElement + (StringElement) + (StringElement)))))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ObjectElement + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (SchemaElement + (MemberElement + (StringElement) + (StringElement)))))))))) + (MemberElement + (StringElement) + (ExternalDocumentationElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))))) +`; diff --git a/packages/apidom-parser-adapter-openapi-json-2/test/adapter.ts b/packages/apidom-parser-adapter-openapi-json-2/test/adapter.ts new file mode 100644 index 0000000000..f7d1624e10 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/test/adapter.ts @@ -0,0 +1,81 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { assert, expect } from 'chai'; +import { isParseResultElement, sexprs } from '@swagger-api/apidom-core'; +import { isSwaggerElement } from '@swagger-api/apidom-ns-openapi-2'; + +import * as adapter from '../src/adapter'; + +const jsonSpec = fs.readFileSync(path.join(__dirname, 'fixtures', 'sample-api.json')).toString(); +const yamlSpec = fs.readFileSync(path.join(__dirname, 'fixtures', 'sample-api.yaml')).toString(); + +describe('adapter', function () { + context('given definition in JSON format', function () { + specify('should detect proper media type', async function () { + assert.isTrue(await adapter.detect(jsonSpec)); + }); + + specify('should not detect minor version bump', async function () { + assert.isFalse(await adapter.detect('{"swagger": "2.1"}')); + }); + + specify('should not detect patch version bump', async function () { + assert.isFalse(await adapter.detect('{"openapi": "2.0.1"}')); + }); + + specify('should not detect minor and patch version bump', async function () { + assert.isFalse(await adapter.detect('{"openapi": "2.1.1"}')); + }); + }); + + context('given definition in YAML 1.2 format', function () { + specify('should detect proper media type', async function () { + assert.isFalse(await adapter.detect(yamlSpec)); + }); + }); + + context('given definition of unknown type', function () { + specify('should detect proper media type', async function () { + assert.isFalse(await adapter.detect('"asyncapi": "2.6.0"')); + }); + }); + + it('should parse', async function () { + const parseResult = await adapter.parse(jsonSpec, { sourceMap: true }); + + assert.isTrue(isParseResultElement(parseResult)); + assert.isTrue(isSwaggerElement(parseResult.api)); + expect(sexprs(parseResult)).toMatchSnapshot(); + }); + + context('given zero byte empty file', function () { + specify('should return empty parse result', async function () { + const parseResult = await adapter.parse('', { sourceMap: true }); + + assert.isTrue(parseResult.isEmpty); + }); + }); + + context('given non-zero byte empty file', function () { + specify('should return empty parser result', async function () { + const parseResult = await adapter.parse(' ', { sourceMap: true }); + + assert.isTrue(parseResult.isEmpty); + }); + }); + + context('given invalid json file', function () { + specify('should return empty parser result', async function () { + const parseResult = await adapter.parse(' a ', { sourceMap: true }); + + assert.isTrue(parseResult.isEmpty); + }); + }); + + context('detectionRegExp', function () { + specify('should reject invalid version ranges', function () { + assert.isFalse(adapter.detectionRegExp.test('"swagger": "2.1"')); + assert.isFalse(adapter.detectionRegExp.test('"swagger": "2.0.1"')); + }); + }); +}); diff --git a/packages/apidom-parser-adapter-openapi-json-2/test/fixtures/sample-api.json b/packages/apidom-parser-adapter-openapi-json-2/test/fixtures/sample-api.json new file mode 100644 index 0000000000..254a03b61a --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/test/fixtures/sample-api.json @@ -0,0 +1,1036 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "version": "1.0.0", + "title": "Swagger Petstore 2.0", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "email": "apiteam@swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "host": "petstore.swagger.io", + "basePath": "/v2", + "tags": [ + { + "name": "pet", + "description": "Everything about your Pets", + "externalDocs": { + "description": "Find out more", + "url": "http://swagger.io" + } + }, + { + "name": "store", + "description": "Access to Petstore orders" + }, + { + "name": "user", + "description": "Operations about user", + "externalDocs": { + "description": "Find out more about our store", + "url": "http://swagger.io" + } + } + ], + "schemes": [ + "https", + "http" + ], + "paths": { + "/pet": { + "post": { + "tags": [ + "pet" + ], + "summary": "Add a new pet to the store", + "description": "", + "operationId": "addPet", + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet object that needs to be added to the store", + "required": true, + "schema": { + "$ref": "#/definitions/Pet" + } + } + ], + "responses": { + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + }, + "put": { + "tags": [ + "pet" + ], + "summary": "Update an existing pet", + "description": "", + "operationId": "updatePet", + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet object that needs to be added to the store", + "required": true, + "schema": { + "$ref": "#/definitions/Pet" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByStatus": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "status", + "in": "query", + "description": "Status values that need to be considered for filter", + "required": true, + "type": "array", + "items": { + "type": "string", + "enum": [ + "available", + "pending", + "sold" + ], + "default": "available" + }, + "collectionFormat": "multi" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Pet" + } + } + }, + "400": { + "description": "Invalid status value" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByTags": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by tags", + "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "Tags to filter by", + "required": true, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Pet" + } + } + }, + "400": { + "description": "Invalid tag value" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ], + "deprecated": true + } + }, + "/pet/{petId}": { + "get": { + "tags": [ + "pet" + ], + "summary": "Find pet by ID", + "description": "Returns a single pet", + "operationId": "getPetById", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to return", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/Pet" + } + }, + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + } + }, + "security": [ + { + "api_key": [] + } + ] + }, + "post": { + "tags": [ + "pet" + ], + "summary": "Updates a pet in the store with form data", + "description": "", + "operationId": "updatePetWithForm", + "consumes": [ + "application/x-www-form-urlencoded" + ], + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet that needs to be updated", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "name", + "in": "formData", + "description": "Updated name of the pet", + "required": false, + "type": "string" + }, + { + "name": "status", + "in": "formData", + "description": "Updated status of the pet", + "required": false, + "type": "string" + } + ], + "responses": { + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + }, + "delete": { + "tags": [ + "pet" + ], + "summary": "Deletes a pet", + "description": "", + "operationId": "deletePet", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "api_key", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "petId", + "in": "path", + "description": "Pet id to delete", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/{petId}/uploadImage": { + "post": { + "tags": [ + "pet" + ], + "summary": "uploads an image", + "description": "", + "operationId": "uploadFile", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to update", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "additionalMetadata", + "in": "formData", + "description": "Additional data to pass to server", + "required": false, + "type": "string" + }, + { + "name": "file", + "in": "formData", + "description": "file to upload", + "required": false, + "type": "file" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/ApiResponse" + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/store/inventory": { + "get": { + "tags": [ + "store" + ], + "summary": "Returns pet inventories by status", + "description": "Returns a map of status codes to quantities", + "operationId": "getInventory", + "produces": [ + "application/json" + ], + "parameters": [], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int32" + } + } + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/store/order": { + "post": { + "tags": [ + "store" + ], + "summary": "Place an order for a pet", + "description": "", + "operationId": "placeOrder", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "order placed for purchasing the pet", + "required": true, + "schema": { + "$ref": "#/definitions/Order" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/Order" + } + }, + "400": { + "description": "Invalid Order" + } + } + } + }, + "/store/order/{orderId}": { + "get": { + "tags": [ + "store" + ], + "summary": "Find purchase order by ID", + "description": "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions", + "operationId": "getOrderById", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of pet that needs to be fetched", + "required": true, + "type": "integer", + "maximum": 10, + "minimum": 1, + "format": "int64" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/Order" + } + }, + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Order not found" + } + } + }, + "delete": { + "tags": [ + "store" + ], + "summary": "Delete purchase order by ID", + "description": "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors", + "operationId": "deleteOrder", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of the order that needs to be deleted", + "required": true, + "type": "integer", + "minimum": 1, + "format": "int64" + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Order not found" + } + } + } + }, + "/user": { + "post": { + "tags": [ + "user" + ], + "summary": "Create user", + "description": "This can only be done by the logged in user.", + "operationId": "createUser", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Created user object", + "required": true, + "schema": { + "$ref": "#/definitions/User" + } + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/user/createWithArray": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "", + "operationId": "createUsersWithArrayInput", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "List of user object", + "required": true, + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + } + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/user/createWithList": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "", + "operationId": "createUsersWithListInput", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "List of user object", + "required": true, + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + } + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/user/login": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs user into the system", + "description": "", + "operationId": "loginUser", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "username", + "in": "query", + "description": "The user name for login", + "required": true, + "type": "string" + }, + { + "name": "password", + "in": "query", + "description": "The password for login in clear text", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "string" + }, + "headers": { + "X-Rate-Limit": { + "type": "integer", + "format": "int32", + "description": "calls per hour allowed by the user" + }, + "X-Expires-After": { + "type": "string", + "format": "date-time", + "description": "date in UTC when token expires" + } + } + }, + "400": { + "description": "Invalid username/password supplied" + } + } + } + }, + "/user/logout": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs out current logged in user session", + "description": "", + "operationId": "logoutUser", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/user/{username}": { + "get": { + "tags": [ + "user" + ], + "summary": "Get user by user name", + "description": "", + "operationId": "getUserByName", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "username", + "in": "path", + "description": "The name that needs to be fetched. Use user1 for testing. ", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/User" + } + }, + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" + } + } + }, + "put": { + "tags": [ + "user" + ], + "summary": "Updated user", + "description": "This can only be done by the logged in user.", + "operationId": "updateUser", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "username", + "in": "path", + "description": "name that need to be updated", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "Updated user object", + "required": true, + "schema": { + "$ref": "#/definitions/User" + } + } + ], + "responses": { + "400": { + "description": "Invalid user supplied" + }, + "404": { + "description": "User not found" + } + } + }, + "delete": { + "tags": [ + "user" + ], + "summary": "Delete user", + "description": "This can only be done by the logged in user.", + "operationId": "deleteUser", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "name": "username", + "in": "path", + "description": "The name that needs to be deleted", + "required": true, + "type": "string" + } + ], + "responses": { + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" + } + } + } + } + }, + "securityDefinitions": { + "petstore_auth": { + "type": "oauth2", + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "flow": "implicit", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + }, + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + } + }, + "definitions": { + "Order": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "petId": { + "type": "integer", + "format": "int64" + }, + "quantity": { + "type": "integer", + "format": "int32" + }, + "shipDate": { + "type": "string", + "format": "date-time" + }, + "status": { + "type": "string", + "description": "Order Status", + "enum": [ + "placed", + "approved", + "delivered" + ] + }, + "complete": { + "type": "boolean", + "default": false + } + }, + "xml": { + "name": "Order" + } + }, + "Category": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + }, + "xml": { + "name": "Category" + } + }, + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "username": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "userStatus": { + "type": "integer", + "format": "int32", + "description": "User Status" + } + }, + "xml": { + "name": "User" + } + }, + "Tag": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + }, + "xml": { + "name": "Tag" + } + }, + "Pet": { + "type": "object", + "required": [ + "name", + "photoUrls" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "category": { + "$ref": "#/definitions/Category" + }, + "name": { + "type": "string", + "example": "doggie" + }, + "photoUrls": { + "type": "array", + "xml": { + "name": "photoUrl", + "wrapped": true + }, + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "xml": { + "name": "tag", + "wrapped": true + }, + "items": { + "$ref": "#/definitions/Tag" + } + }, + "status": { + "type": "string", + "description": "pet status in the store", + "enum": [ + "available", + "pending", + "sold" + ] + } + }, + "xml": { + "name": "Pet" + } + }, + "ApiResponse": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + }, + "externalDocs": { + "description": "Find out more about Swagger", + "url": "http://swagger.io" + } +} diff --git a/packages/apidom-parser-adapter-openapi-json-2/test/fixtures/sample-api.yaml b/packages/apidom-parser-adapter-openapi-json-2/test/fixtures/sample-api.yaml new file mode 100644 index 0000000000..2bd02b2bb0 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/test/fixtures/sample-api.yaml @@ -0,0 +1,700 @@ +swagger: "2.0" +info: + description: "This is a sample server Petstore server. You can find out more about \ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). \ For this sample, you can use the api key `special-key` to test the authorization \ filters." + version: "1.0.0" + title: "Swagger Petstore 2.0" + termsOfService: "http://swagger.io/terms/" + contact: + email: "apiteam@swagger.io" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" +host: "petstore.swagger.io" +basePath: "/v2" +tags: + - name: "pet" + description: "Everything about your Pets" + externalDocs: + description: "Find out more" + url: "http://swagger.io" + - name: "store" + description: "Access to Petstore orders" + - name: "user" + description: "Operations about user" + externalDocs: + description: "Find out more about our store" + url: "http://swagger.io" +schemes: + - "https" + - "http" +paths: + /pet: + post: + tags: + - "pet" + summary: "Add a new pet to the store" + description: "" + operationId: "addPet" + consumes: + - "application/json" + - "application/xml" + produces: + - "application/xml" + - "application/json" + parameters: + - in: "body" + name: "body" + description: "Pet object that needs to be added to the store" + required: true + schema: + $ref: "#/definitions/Pet" + responses: + "405": + description: "Invalid input" + security: + - petstore_auth: + - "write:pets" + - "read:pets" + put: + tags: + - "pet" + summary: "Update an existing pet" + description: "" + operationId: "updatePet" + consumes: + - "application/json" + - "application/xml" + produces: + - "application/xml" + - "application/json" + parameters: + - in: "body" + name: "body" + description: "Pet object that needs to be added to the store" + required: true + schema: + $ref: "#/definitions/Pet" + responses: + "400": + description: "Invalid ID supplied" + "404": + description: "Pet not found" + "405": + description: "Validation exception" + security: + - petstore_auth: + - "write:pets" + - "read:pets" + /pet/findByStatus: + get: + tags: + - "pet" + summary: "Finds Pets by status" + description: "Multiple status values can be provided with comma separated strings" + operationId: "findPetsByStatus" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "status" + in: "query" + description: "Status values that need to be considered for filter" + required: true + type: "array" + items: + type: "string" + enum: + - "available" + - "pending" + - "sold" + default: "available" + collectionFormat: "multi" + responses: + "200": + description: "successful operation" + schema: + type: "array" + items: + $ref: "#/definitions/Pet" + "400": + description: "Invalid status value" + security: + - petstore_auth: + - "write:pets" + - "read:pets" + /pet/findByTags: + get: + tags: + - "pet" + summary: "Finds Pets by tags" + description: "Muliple tags can be provided with comma separated strings. Use \ tag1, tag2, tag3 for testing." + operationId: "findPetsByTags" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "tags" + in: "query" + description: "Tags to filter by" + required: true + type: "array" + items: + type: "string" + collectionFormat: "multi" + responses: + "200": + description: "successful operation" + schema: + type: "array" + items: + $ref: "#/definitions/Pet" + "400": + description: "Invalid tag value" + security: + - petstore_auth: + - "write:pets" + - "read:pets" + deprecated: true + /pet/{petId}: + get: + tags: + - "pet" + summary: "Find pet by ID" + description: "Returns a single pet" + operationId: "getPetById" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "petId" + in: "path" + description: "ID of pet to return" + required: true + type: "integer" + format: "int64" + responses: + "200": + description: "successful operation" + schema: + $ref: "#/definitions/Pet" + "400": + description: "Invalid ID supplied" + "404": + description: "Pet not found" + security: + - api_key: [] + post: + tags: + - "pet" + summary: "Updates a pet in the store with form data" + description: "" + operationId: "updatePetWithForm" + consumes: + - "application/x-www-form-urlencoded" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "petId" + in: "path" + description: "ID of pet that needs to be updated" + required: true + type: "integer" + format: "int64" + - name: "name" + in: "formData" + description: "Updated name of the pet" + required: false + type: "string" + - name: "status" + in: "formData" + description: "Updated status of the pet" + required: false + type: "string" + responses: + "405": + description: "Invalid input" + security: + - petstore_auth: + - "write:pets" + - "read:pets" + delete: + tags: + - "pet" + summary: "Deletes a pet" + description: "" + operationId: "deletePet" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "api_key" + in: "header" + required: false + type: "string" + - name: "petId" + in: "path" + description: "Pet id to delete" + required: true + type: "integer" + format: "int64" + responses: + "400": + description: "Invalid ID supplied" + "404": + description: "Pet not found" + security: + - petstore_auth: + - "write:pets" + - "read:pets" + /pet/{petId}/uploadImage: + post: + tags: + - "pet" + summary: "uploads an image" + description: "" + operationId: "uploadFile" + consumes: + - "multipart/form-data" + produces: + - "application/json" + parameters: + - name: "petId" + in: "path" + description: "ID of pet to update" + required: true + type: "integer" + format: "int64" + - name: "additionalMetadata" + in: "formData" + description: "Additional data to pass to server" + required: false + type: "string" + - name: "file" + in: "formData" + description: "file to upload" + required: false + type: "file" + responses: + "200": + description: "successful operation" + schema: + $ref: "#/definitions/ApiResponse" + security: + - petstore_auth: + - "write:pets" + - "read:pets" + /store/inventory: + get: + tags: + - "store" + summary: "Returns pet inventories by status" + description: "Returns a map of status codes to quantities" + operationId: "getInventory" + produces: + - "application/json" + parameters: [] + responses: + "200": + description: "successful operation" + schema: + type: "object" + additionalProperties: + type: "integer" + format: "int32" + security: + - api_key: [] + /store/order: + post: + tags: + - "store" + summary: "Place an order for a pet" + description: "" + operationId: "placeOrder" + produces: + - "application/xml" + - "application/json" + parameters: + - in: "body" + name: "body" + description: "order placed for purchasing the pet" + required: true + schema: + $ref: "#/definitions/Order" + responses: + "200": + description: "successful operation" + schema: + $ref: "#/definitions/Order" + "400": + description: "Invalid Order" + /store/order/{orderId}: + get: + tags: + - "store" + summary: "Find purchase order by ID" + description: "For valid response try integer IDs with value >= 1 and <= 10. \ Other values will generated exceptions" + operationId: "getOrderById" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "orderId" + in: "path" + description: "ID of pet that needs to be fetched" + required: true + type: "integer" + maximum: 10.0 + minimum: 1.0 + format: "int64" + responses: + "200": + description: "successful operation" + schema: + $ref: "#/definitions/Order" + "400": + description: "Invalid ID supplied" + "404": + description: "Order not found" + delete: + tags: + - "store" + summary: "Delete purchase order by ID" + description: "For valid response try integer IDs with positive integer value. \ Negative or non-integer values will generate API errors" + operationId: "deleteOrder" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "orderId" + in: "path" + description: "ID of the order that needs to be deleted" + required: true + type: "integer" + minimum: 1.0 + format: "int64" + responses: + "400": + description: "Invalid ID supplied" + "404": + description: "Order not found" + /user: + post: + tags: + - "user" + summary: "Create user" + description: "This can only be done by the logged in user." + operationId: "createUser" + produces: + - "application/xml" + - "application/json" + parameters: + - in: "body" + name: "body" + description: "Created user object" + required: true + schema: + $ref: "#/definitions/User" + responses: + default: + description: "successful operation" + /user/createWithArray: + post: + tags: + - "user" + summary: "Creates list of users with given input array" + description: "" + operationId: "createUsersWithArrayInput" + produces: + - "application/xml" + - "application/json" + parameters: + - in: "body" + name: "body" + description: "List of user object" + required: true + schema: + type: "array" + items: + $ref: "#/definitions/User" + responses: + default: + description: "successful operation" + /user/createWithList: + post: + tags: + - "user" + summary: "Creates list of users with given input array" + description: "" + operationId: "createUsersWithListInput" + produces: + - "application/xml" + - "application/json" + parameters: + - in: "body" + name: "body" + description: "List of user object" + required: true + schema: + type: "array" + items: + $ref: "#/definitions/User" + responses: + default: + description: "successful operation" + /user/login: + get: + tags: + - "user" + summary: "Logs user into the system" + description: "" + operationId: "loginUser" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "username" + in: "query" + description: "The user name for login" + required: true + type: "string" + - name: "password" + in: "query" + description: "The password for login in clear text" + required: true + type: "string" + responses: + "200": + description: "successful operation" + schema: + type: "string" + headers: + X-Rate-Limit: + type: "integer" + format: "int32" + description: "calls per hour allowed by the user" + X-Expires-After: + type: "string" + format: "date-time" + description: "date in UTC when token expires" + "400": + description: "Invalid username/password supplied" + /user/logout: + get: + tags: + - "user" + summary: "Logs out current logged in user session" + description: "" + operationId: "logoutUser" + produces: + - "application/xml" + - "application/json" + parameters: [] + responses: + default: + description: "successful operation" + /user/{username}: + get: + tags: + - "user" + summary: "Get user by user name" + description: "" + operationId: "getUserByName" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "username" + in: "path" + description: "The name that needs to be fetched. Use user1 for testing. " + required: true + type: "string" + responses: + "200": + description: "successful operation" + schema: + $ref: "#/definitions/User" + "400": + description: "Invalid username supplied" + "404": + description: "User not found" + put: + tags: + - "user" + summary: "Updated user" + description: "This can only be done by the logged in user." + operationId: "updateUser" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "username" + in: "path" + description: "name that need to be updated" + required: true + type: "string" + - in: "body" + name: "body" + description: "Updated user object" + required: true + schema: + $ref: "#/definitions/User" + responses: + "400": + description: "Invalid user supplied" + "404": + description: "User not found" + delete: + tags: + - "user" + summary: "Delete user" + description: "This can only be done by the logged in user." + operationId: "deleteUser" + produces: + - "application/xml" + - "application/json" + parameters: + - name: "username" + in: "path" + description: "The name that needs to be deleted" + required: true + type: "string" + responses: + "400": + description: "Invalid username supplied" + "404": + description: "User not found" +securityDefinitions: + petstore_auth: + type: "oauth2" + authorizationUrl: "http://petstore.swagger.io/oauth/dialog" + flow: "implicit" + scopes: + write:pets: "modify pets in your account" + read:pets: "read your pets" + api_key: + type: "apiKey" + name: "api_key" + in: "header" +definitions: + Order: + type: "object" + properties: + id: + type: "integer" + format: "int64" + petId: + type: "integer" + format: "int64" + quantity: + type: "integer" + format: "int32" + shipDate: + type: "string" + format: "date-time" + status: + type: "string" + description: "Order Status" + enum: + - "placed" + - "approved" + - "delivered" + complete: + type: "boolean" + default: false + xml: + name: "Order" + Category: + type: "object" + properties: + id: + type: "integer" + format: "int64" + name: + type: "string" + xml: + name: "Category" + User: + type: "object" + properties: + id: + type: "integer" + format: "int64" + username: + type: "string" + firstName: + type: "string" + lastName: + type: "string" + email: + type: "string" + password: + type: "string" + phone: + type: "string" + userStatus: + type: "integer" + format: "int32" + description: "User Status" + xml: + name: "User" + Tag: + type: "object" + properties: + id: + type: "integer" + format: "int64" + name: + type: "string" + xml: + name: "Tag" + Pet: + type: "object" + required: + - "name" + - "photoUrls" + properties: + id: + type: "integer" + format: "int64" + category: + $ref: "#/definitions/Category" + name: + type: "string" + example: "doggie" + photoUrls: + type: "array" + xml: + name: "photoUrl" + wrapped: true + items: + type: "string" + tags: + type: "array" + xml: + name: "tag" + wrapped: true + items: + $ref: "#/definitions/Tag" + status: + type: "string" + description: "pet status in the store" + enum: + - "available" + - "pending" + - "sold" + xml: + name: "Pet" + ApiResponse: + type: "object" + properties: + code: + type: "integer" + format: "int32" + type: + type: "string" + message: + type: "string" +externalDocs: + description: "Find out more about Swagger" + url: "http://swagger.io" diff --git a/packages/apidom-parser-adapter-openapi-json-2/test/media-types.ts b/packages/apidom-parser-adapter-openapi-json-2/test/media-types.ts new file mode 100644 index 0000000000..0269f0536c --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/test/media-types.ts @@ -0,0 +1,24 @@ +import { assert } from 'chai'; +import ApiDOMParser from '@swagger-api/apidom-parser'; + +import * as openApiJsonAdapter from '../src/adapter'; + +describe('given adapter is used in parser', function () { + const parser = ApiDOMParser().use(openApiJsonAdapter); + + context('given OpenAPI 2.0 definition in JSON format', function () { + specify('should find appropriate media type', async function () { + const mediaType = await parser.findMediaType('{"swagger": "2.0"}'); + + assert.strictEqual(mediaType, 'application/vnd.oai.openapi+json;version=2.0'); + }); + }); + + context('given OpenAPI 3.0.3 definition in JSON format', function () { + specify('should not find appropriate media type', async function () { + const mediaType = await parser.findMediaType('{"openapi": "3.1.0"}'); + + assert.strictEqual(mediaType, 'application/octet-stream'); + }); + }); +}); diff --git a/packages/apidom-parser-adapter-openapi-json-2/test/mocha-bootstrap.cjs b/packages/apidom-parser-adapter-openapi-json-2/test/mocha-bootstrap.cjs new file mode 100644 index 0000000000..bc8ce3c8fc --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/test/mocha-bootstrap.cjs @@ -0,0 +1,15 @@ +/* eslint-disable */ +require('@babel/register')({ extensions: ['.js', '.ts'], rootMode: 'upward' }); + +/** + * Configure snapshot testing. + */ +const chai = require('chai'); +const { jestSnapshotPlugin, addSerializer } = require('mocha-chai-jest-snapshot'); + +const jestApiDOMSerializer = require('../../../scripts/jest-serializer-apidom.cjs'); +const jestStringSerializer = require('../../../scripts/jest-serializer-string.cjs'); + +chai.use(jestSnapshotPlugin()); +addSerializer(jestApiDOMSerializer); +addSerializer(jestStringSerializer); diff --git a/packages/apidom-parser-adapter-openapi-json-2/tsconfig.json b/packages/apidom-parser-adapter-openapi-json-2/tsconfig.json new file mode 100644 index 0000000000..4081635a03 --- /dev/null +++ b/packages/apidom-parser-adapter-openapi-json-2/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": [ + "src/**/*", + "test/**/*" + ] +} diff --git a/packages/apidom-parser-adapter-openapi-json-3-0/README.md b/packages/apidom-parser-adapter-openapi-json-3-0/README.md index 964559407c..fbb3d0a0f5 100644 --- a/packages/apidom-parser-adapter-openapi-json-3-0/README.md +++ b/packages/apidom-parser-adapter-openapi-json-3-0/README.md @@ -1,9 +1,9 @@ # @swagger-api/apidom-parser-adapter-openapi-json-3-0 -`@swagger-api/apidom-parser-adapter-openapi-json-3-0` is a parser adapter for the [OpenApi 3.0.x specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md) in [JSON format](https://www.json.org/json-en.html). +`@swagger-api/apidom-parser-adapter-openapi-json-3-0` is a parser adapter for the [OpenAPI 3.0.x specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md) in [JSON format](https://www.json.org/json-en.html). Under the hood this adapter uses [apidom-parser-adapter-json](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-json) to parse a source string into generic ApiDOM in [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace) -which is then refracted with [OpenApi 3.0.x Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#refractors). +which is then refracted with [OpenAPI 3.0.x Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#refractors). ## Installation @@ -38,11 +38,11 @@ Defines list of media types that this parser adapter recognizes. ### detect -[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-openapi-json-3-0/src/adapter.ts#L13) is based on a regular expression matching required OpenApi 3.0.x specification symbols in JSON format. +[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-openapi-json-3-0/src/adapter.ts#L13) is based on a regular expression matching required OpenAPI 3.0.x specification symbols in JSON format. ### namespace -This adapter exposes an instance of [OpenApi 3.0.x ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#openapi-30x-namespace). +This adapter exposes an instance of [OpenAPI 3.0.x ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#openapi-30x-namespace). ### parse diff --git a/packages/apidom-parser-adapter-openapi-json-3-1/README.md b/packages/apidom-parser-adapter-openapi-json-3-1/README.md index a914e2a269..ae83dc40bc 100644 --- a/packages/apidom-parser-adapter-openapi-json-3-1/README.md +++ b/packages/apidom-parser-adapter-openapi-json-3-1/README.md @@ -1,9 +1,9 @@ # @swagger-api/apidom-parser-adapter-openapi-json-3-1 -`@swagger-api/apidom-parser-adapter-openapi-json-3-1` is a parser adapter for the [OpenApi 3.1.0 specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md) in [JSON format](https://www.json.org/json-en.html). +`@swagger-api/apidom-parser-adapter-openapi-json-3-1` is a parser adapter for the [OpenAPI 3.1.0 specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md) in [JSON format](https://www.json.org/json-en.html). Under the hood this adapter uses [apidom-parser-adapter-json](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-json) to parse a source string into generic ApiDOM in [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace) -which is then refracted with [OpenApi 3.1.0 Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1#refractors). +which is then refracted with [OpenAPI 3.1.0 Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1#refractors). ## Installation @@ -32,11 +32,11 @@ Defines list of media types that this parser adapter recognizes. ### detect -[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-openapi-json-3-1/src/adapter.ts#L13) is based on a regular expression matching required OpenApi 3.1.0 specification symbols in JSON format. +[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-openapi-json-3-1/src/adapter.ts#L13) is based on a regular expression matching required OpenAPI 3.1.0 specification symbols in JSON format. ### namespace -This adapter exposes an instance of [OpenApi 3.1.0 ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1#openapi-310-namespace). +This adapter exposes an instance of [OpenAPI 3.1.0 ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1#openapi-310-namespace). ### parse diff --git a/packages/apidom-parser-adapter-openapi-yaml-3-0/README.md b/packages/apidom-parser-adapter-openapi-yaml-3-0/README.md index b590498a89..779c3b0154 100644 --- a/packages/apidom-parser-adapter-openapi-yaml-3-0/README.md +++ b/packages/apidom-parser-adapter-openapi-yaml-3-0/README.md @@ -1,9 +1,9 @@ # @swagger-api/apidom-parser-adapter-openapi-yaml-3-0 -`@swagger-api/apidom-parser-adapter-openapi-yaml-3-0` is a parser adapter for the [OpenApi 3.0.x specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md) in [YAML format](https://yaml.org/spec/1.2/spec.html). +`@swagger-api/apidom-parser-adapter-openapi-yaml-3-0` is a parser adapter for the [OpenAPI 3.0.x specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md) in [YAML format](https://yaml.org/spec/1.2/spec.html). Under the hood this adapter uses [apidom-parser-adapter-yaml-1-2](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-yaml-1-2) to parse a source string into generic ApiDOM in [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace) -which is then refracted with [OpenApi 3.0.x Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#refractors). +which is then refracted with [OpenAPI 3.0.x Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#refractors). ## Installation @@ -38,11 +38,11 @@ Defines list of media types that this parser adapter recognizes. ### detect -[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-openapi-yaml-3-0/src/adapter.ts#L13) is based on a regular expression matching required OpenApi 3.0.x specification symbols in YAML format. +[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-openapi-yaml-3-0/src/adapter.ts#L13) is based on a regular expression matching required OpenAPI 3.0.x specification symbols in YAML format. ### namespace -This adapter exposes an instance of [OpenApi 3.0.x ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#openapi-30x-namespace). +This adapter exposes an instance of [OpenAPI 3.0.x ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#openapi-30x-namespace). ### parse diff --git a/packages/apidom-parser-adapter-openapi-yaml-3-1/README.md b/packages/apidom-parser-adapter-openapi-yaml-3-1/README.md index c203d7edbe..d82b86e0a9 100644 --- a/packages/apidom-parser-adapter-openapi-yaml-3-1/README.md +++ b/packages/apidom-parser-adapter-openapi-yaml-3-1/README.md @@ -1,9 +1,9 @@ # @swagger-api/apidom-parser-adapter-openapi-yaml-3-1 -`@swagger-api/apidom-parser-adapter-openapi-yaml-3-1` is a parser adapter for the [OpenApi 3.1.0 specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md) in [YAML format](https://yaml.org/spec/1.2/spec.html). +`@swagger-api/apidom-parser-adapter-openapi-yaml-3-1` is a parser adapter for the [OpenAPI 3.1.0 specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md) in [YAML format](https://yaml.org/spec/1.2/spec.html). Under the hood this adapter uses [apidom-parser-adapter-yaml-1-2](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-yaml-1-2) to parse a source string into generic ApiDOM in [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace) -which is then refracted with [OpenApi 3.1.0 Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1#refractors). +which is then refracted with [OpenAPI 3.1.0 Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1#refractors). ## Installation @@ -32,11 +32,11 @@ Defines list of media types that this parser adapter recognizes. ### detect -[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-openapi-yaml-3-1/src/adapter.ts#L13) is based on a regular expression matching required OpenApi 3.1.0 specification symbols in YAML format. +[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-openapi-yaml-3-1/src/adapter.ts#L13) is based on a regular expression matching required OpenAPI 3.1.0 specification symbols in YAML format. ### namespace -This adapter exposes an instance of [OpenApi 3.1.0 ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1#openapi-310-namespace). +This adapter exposes an instance of [OpenAPI 3.1.0 ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-1#openapi-310-namespace). ### parse