From 49ffda64ca8952daa7511ce1f3b05932d6771170 Mon Sep 17 00:00:00 2001 From: Maximilian Mayer Date: Mon, 13 Jan 2025 14:29:35 +0100 Subject: [PATCH 1/3] chore/fix-prettier --- .github/ISSUE_TEMPLATE/bug_report.md | 3 +- .github/ISSUE_TEMPLATE/feature_request.md | 1 - .github/dependabot.yml | 7 +- .github/workflows/default.yml | 2 +- .travis.yml | 28 +- CHANGE_HISTORY.md | 542 ++++---- CODE_OF_CONDUCT.md | 26 +- CONTRIBUTING.md | 13 +- README.md | 6 +- SECURITY.md | 1 - _config.yml | 2 +- examples/1-standard-oas-3.1/README.md | 12 +- examples/1-standard-oas-3.1/app.js | 1 - examples/1-standard-oas-3.1/services/index.js | 13 +- examples/1-standard/services/index.js | 6 +- examples/3-eov-operations/routes/pets.js | 2 +- examples/3-eov-operations/services/index.js | 8 +- examples/4-eov-operations-babel/.babelrc | 18 +- examples/4-eov-operations-babel/src/api.yaml | 4 +- .../4-eov-operations-babel/src/routes/pets.js | 2 +- .../src/services/index.js | 8 +- .../5-custom-operation-resolver/README.md | 10 +- examples/5-custom-operation-resolver/api.yaml | 2 +- .../routes/pets.js | 2 +- .../services/index.js | 8 +- examples/6-multi-file-spec/README.md | 7 +- examples/6-multi-file-spec/ems.yaml | 2 +- .../6-multi-file-spec/schemas/queries.yaml | 2 +- .../schemas/queryrequest.yaml | 2 +- .../schemas/queryrequests.yaml | 2 +- .../7-response-date-serialization/api.yaml | 7 +- launch.json | 1 - src/framework/ajv/factory.ts | 16 +- src/framework/ajv/index.ts | 32 +- src/framework/ajv/options.ts | 18 +- src/framework/base.path.ts | 16 +- src/framework/base.serdes.ts | 17 +- src/framework/index.ts | 4 +- src/framework/json.ref.schema.ts | 1 - src/framework/modded.express.mung.ts | 18 +- src/framework/openapi.context.ts | 4 +- src/framework/openapi.schema.validator.ts | 10 +- src/framework/openapi.spec.loader.ts | 12 +- src/framework/openapi/assert.version.ts | 16 +- src/framework/openapi/factory.schema.ts | 8 +- src/framework/types.ts | 67 +- src/middlewares/openapi.metadata.ts | 4 +- src/middlewares/openapi.multipart.ts | 6 +- src/middlewares/openapi.request.validator.ts | 8 +- src/middlewares/openapi.security.ts | 36 +- src/middlewares/parsers/body.parse.ts | 21 +- .../parsers/req.parameter.mutator.ts | 35 +- src/middlewares/parsers/schema.parse.ts | 5 +- .../parsers/schema.preprocessor.ts | 47 +- src/middlewares/util.ts | 29 +- src/openapi.validator.ts | 40 +- src/resolvers.ts | 5 +- test/1022.spec.ts | 4 +- test/356.campaign.spec.ts | 2 +- test/356.campaign.yaml | 6 +- test/440.spec.ts | 23 +- test/577.spec.ts | 17 +- test/699.spec.ts | 126 +- test/821.spec.ts | 31 +- .../ajv.resolves.more.than.one.schema.spec.ts | 46 +- test/common/app.common.ts | 103 +- test/common/app.ts | 2 +- test/common/test.yaml | 2 +- test/component.params.spec.ts | 4 +- test/content.type.spec.ts | 5 +- test/datetime.validation.spec.ts | 31 +- test/default-export.spec.ts | 4 +- test/default.export.fn.spec.ts | 8 +- test/escaped.characters.in.ref.path.spec.ts | 57 +- test/headers.2.spec.ts | 4 +- test/headers.spec.ts | 12 +- test/httperror.spec.ts | 4 +- test/ignore.paths.spec.ts | 16 +- test/multi.spec.spec.ts | 2 +- test/multipart.disabled.spec.ts | 14 +- test/multipart.spec.ts | 9 +- test/nested.routes.spec.ts | 27 +- test/one.of.spec.ts | 14 +- test/oneof.readonly.yaml | 90 +- test/openapi.spec.ts | 74 +- test/openapi_3.1/components.spec.ts | 11 +- .../openapi_3.1/components_path_items.spec.ts | 31 +- test/openapi_3.1/info_summary.spec.ts | 18 +- test/openapi_3.1/license_identifier.spec.ts | 18 +- ...non_defined_semantics_request_body.spec.ts | 28 +- test/openapi_3.1/path_no_response.spec.ts | 31 +- test/openapi_3.1/resources/components.yaml | 2 +- .../resources/components_path_items.yaml | 10 +- test/openapi_3.1/resources/info_summary.yaml | 2 +- .../resources/license_identifier.yaml | 2 +- .../non_defined_semantics_request_body.yaml | 6 +- .../resources/path_no_response.yaml | 2 +- .../resources/server_variable_no_default.yaml | 3 +- test/openapi_3.1/resources/type_null.yaml | 27 +- .../resources/unevaluated_properties.yaml | 2 +- test/openapi_3.1/resources/webhook.yaml | 6 +- test/openapi_3.1/server_variable.spec.ts | 21 +- test/openapi_3.1/type_null.spec.ts | 22 +- .../unevaluated_properties.spec.ts | 31 +- test/openapi_3.1/webhook.spec.ts | 11 +- test/optional-request-body.spec.ts | 4 +- test/path.level.parameters.spec.ts | 12 +- test/paths.sort.spec.ts | 6 +- test/query.params.allow.unknown.spec.ts | 4 +- test/query.params.spec.ts | 16 +- test/query.serialization.ts | 8 +- test/read.only.removeadditional.spec.ts | 153 +-- test/read.only.spec.ts | 10 +- test/request.bodies.ref.spec.ts | 4 +- test/resources/699.yaml | 35 +- test/resources/821.yaml | 2 +- .../additional.props.query.params.yaml | 2 - test/resources/all.of.yaml | 8 +- test/resources/circular.yaml | 6 +- test/resources/coercion.yaml | 20 +- test/resources/controller-with-default.ts | 2 +- test/resources/empty.servers.yaml | 1 - test/resources/eov-operations.modulepath.yaml | 6 +- test/resources/eov-operations.yaml | 4 +- .../resources/escaped.characters.in.path.yaml | 12 +- test/resources/formats.yaml | 5 +- test/resources/headers.yaml | 4 +- test/resources/ignore.paths.yaml | 10 +- test/resources/multipart.yaml | 10 +- test/resources/multiple-validations.yaml | 4 +- test/resources/nested.routes.yaml | 2 +- test/resources/one.of.2.yaml | 8 +- test/resources/one.of.yaml | 39 +- test/resources/openapi.json | 1113 ++++++++--------- test/resources/openapi.yaml | 2 +- test/resources/path.order.yaml | 12 +- test/resources/path.params.yaml | 24 +- test/resources/query.params.yaml | 4 +- test/resources/query.serialization.yaml | 11 +- test/resources/read.only.yaml | 6 +- .../resources/response.object.serializer.yaml | 10 +- .../response.validation.defaults.yaml | 70 +- test/resources/response.validation.yaml | 2 +- test/resources/routes/pets.js | 4 +- test/resources/routes/user.js | 2 +- test/resources/security.top.level.yaml | 2 +- test/resources/security.yaml | 46 +- test/resources/serdes.yaml | 32 +- .../serialized-deep-object.objects.yaml | 18 +- .../serialized.objects.defaults.yaml | 8 +- test/resources/serialized.objects.yaml | 40 +- test/resources/servers.1.yaml | 2 +- test/resources/servers.2.yaml | 2 +- test/resources/services/index.js | 8 +- test/resources/sub_files/paths/auth.yaml | 34 +- test/resources/unknown.formats.yaml | 7 +- test/resources/unknown.keywords.yaml | 4 +- test/resources/wildcard.path.params.yaml | 4 +- test/resources/write.only.yaml | 8 +- test/resources/xt.newpet.yaml | 2 +- test/resources/xt.openapi.parameters.yaml | 2 +- test/response.object.serializer.spec.ts | 14 +- test/response.validation.coerce.types.spec.ts | 4 +- test/response.validation.on.error.spec.ts | 18 +- test/response.validator.spec.ts | 24 +- test/security.defaults.spec.ts | 32 +- test/security.disabled.spec.ts | 12 +- test/security.top.level.spec.ts | 20 +- test/serdes.spec.ts | 225 ++-- test/servers.spec.ts | 87 +- 170 files changed, 2313 insertions(+), 2245 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index d28006d7..b0b7948f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,6 @@ about: Create a report to help us improve title: '' labels: '' assignees: '' - --- **Describe the bug** @@ -13,7 +12,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior. -**Actual behavior** +**Actual behavior** A clear and concise description of what happens. **Expected behavior** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d..2f28cead 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: '' labels: '' assignees: '' - --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6143fb25..130464ae 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,8 +5,7 @@ version: 2 updates: - - package-ecosystem: "" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: '' # See documentation for possible values + directory: '/' # Location of package manifests schedule: - interval: "daily" - + interval: 'daily' diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index efbc4695..b249178a 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -15,4 +15,4 @@ jobs: - name: Build the project run: npm run compile - name: Test the project - run: npm test \ No newline at end of file + run: npm test diff --git a/.travis.yml b/.travis.yml index 3d8e26f0..f4c7a929 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,25 @@ sudo: required language: node_js node_js: -- '14' -- '12' -- '10' + - '14' + - '12' + - '10' before_install: -- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_deba340dfe89_key -iv $encrypted_deba340dfe89_iv - -in secrets.zip.enc -out secrets.zip -d; fi' -- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then unzip secrets.zip; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_deba340dfe89_key -iv $encrypted_deba340dfe89_iv + -in secrets.zip.enc -out secrets.zip -d; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then unzip secrets.zip; fi' install: -- npm install + - npm install script: -- npm run compile -- npm run test:coverage -- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run coveralls; fi' -- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run codacy; fi' + - npm run compile + - npm run test:coverage + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run coveralls; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run codacy; fi' env: global: - - secure: x+Nxbq8RrOVJyQ7JWNRpXdBmp61rXPKulYPxUwGeIe/ZJwX1QHsy2HAAB2m7aRvAMBAqr2urBaIKgPBmBklyY0elRTD/chUdT5cJiPhMIxBghqkQ1NYqx/WzcCBUrZbRzoQcpAES7sJnUs0PMujKv3wMsujoFJ9b9Z+trHMqD0IztBlg45azAh4A6ApVcDB8j4L+g42kps6d4r5jUt2d4uW537PKXpsnWJMaaj2Pw7pxU2H5kBaeNGnvlK+w9k3porToop7OUG+HBTN2BjofdF1PSHm8fizzFL6/h2x39cLYMxFvHb7oVUKBiWQe8PBXD5+k/X0RgPJMZO9AggMHln5MIihTowGvuSLK/3d95ta/qXTmzG0Csv4J8xWD+koCJm0xpSzsrBSUOPt5ZKN71o0VmLmc7U4Z0aEplZyVcMdTbwA1XeoeXD4UU1fD7BlzYl4oOTB8HlucJILwAZFg0upPB33lQchAUIgoUCDxze3OoG3V1Odcw4u64bXlPrdqgCg8AQZgnrYP+EzKczjGd7pBQZRVxKyq+44JV8JOUAXEka3qQRPvmw5wcAaXgsqU7uv1C6FcQb+j/ZKQ6GlWu8qDzouRR+OqbKeLk2lOvtU08Y32tn6u14+vVNbmsG3iXxGf2+esGcETFP/0EYluPGpo257h/9qC1yMN8ZExey0= - - secure: l5s8AWcMM9Ih8aq1OElM47vBI+NS06EB/7k19r7xsurU6+t7s1CoqdJn3HDzUfKax54HtJZzkbAAnfIhVJNIvC9srInW0fRCbD6hW9qS8o0HYDb7dakFa1/CxzoQv8Wz+xus9+Gx2IUJPGJ4ZzVGak704KW0Ds5CFnzQTorohyl/2a6jlODd2gAZMciJA0ZjQGiQPRYpt73cHa5QN03n5Buybp/m0ErsA2Wc7OZONTl0oW0hoQ0A8hICUP1nIbrZjavw8tIf5cComp9GxuatbFCRCaOu5kgbM/O5x0bKJkJutVabO1HC2dYd78o+X7e9ApH+Oly9cLEsuLyYLWnH5Kbdv2j/Huz6wP8H6is4FQUgasTUCcV5+9og6mSccoKDHIvuy0c5lkC30wuaiXJAAWSeohZ8lM6SnrDNp7Q+5mWx5ooVo4A6AGLdXNFeIkqmBat59eNijlnspkJ7MRp2+5mVI+rTyX+fwjLw6Z/1oY5GA9NY061+yPs8LL0BQYkm5r1et3lTIWGo3bJeLIZM4Dsh+VXv1Z8q7oz1PkhSwbmQH19FyQdeohgyzokidbQhGTgk8tO2ol1j2tZMPkwAh3MTRU4Gpmo641Qye69TMhBrhIb5ebmTFXt8HnRbfJT0x/hLjLdCd8hUzo27ICu7yCqZTR74RfIdBvIumSvGQJQ= + - secure: x+Nxbq8RrOVJyQ7JWNRpXdBmp61rXPKulYPxUwGeIe/ZJwX1QHsy2HAAB2m7aRvAMBAqr2urBaIKgPBmBklyY0elRTD/chUdT5cJiPhMIxBghqkQ1NYqx/WzcCBUrZbRzoQcpAES7sJnUs0PMujKv3wMsujoFJ9b9Z+trHMqD0IztBlg45azAh4A6ApVcDB8j4L+g42kps6d4r5jUt2d4uW537PKXpsnWJMaaj2Pw7pxU2H5kBaeNGnvlK+w9k3porToop7OUG+HBTN2BjofdF1PSHm8fizzFL6/h2x39cLYMxFvHb7oVUKBiWQe8PBXD5+k/X0RgPJMZO9AggMHln5MIihTowGvuSLK/3d95ta/qXTmzG0Csv4J8xWD+koCJm0xpSzsrBSUOPt5ZKN71o0VmLmc7U4Z0aEplZyVcMdTbwA1XeoeXD4UU1fD7BlzYl4oOTB8HlucJILwAZFg0upPB33lQchAUIgoUCDxze3OoG3V1Odcw4u64bXlPrdqgCg8AQZgnrYP+EzKczjGd7pBQZRVxKyq+44JV8JOUAXEka3qQRPvmw5wcAaXgsqU7uv1C6FcQb+j/ZKQ6GlWu8qDzouRR+OqbKeLk2lOvtU08Y32tn6u14+vVNbmsG3iXxGf2+esGcETFP/0EYluPGpo257h/9qC1yMN8ZExey0= + - secure: l5s8AWcMM9Ih8aq1OElM47vBI+NS06EB/7k19r7xsurU6+t7s1CoqdJn3HDzUfKax54HtJZzkbAAnfIhVJNIvC9srInW0fRCbD6hW9qS8o0HYDb7dakFa1/CxzoQv8Wz+xus9+Gx2IUJPGJ4ZzVGak704KW0Ds5CFnzQTorohyl/2a6jlODd2gAZMciJA0ZjQGiQPRYpt73cHa5QN03n5Buybp/m0ErsA2Wc7OZONTl0oW0hoQ0A8hICUP1nIbrZjavw8tIf5cComp9GxuatbFCRCaOu5kgbM/O5x0bKJkJutVabO1HC2dYd78o+X7e9ApH+Oly9cLEsuLyYLWnH5Kbdv2j/Huz6wP8H6is4FQUgasTUCcV5+9og6mSccoKDHIvuy0c5lkC30wuaiXJAAWSeohZ8lM6SnrDNp7Q+5mWx5ooVo4A6AGLdXNFeIkqmBat59eNijlnspkJ7MRp2+5mVI+rTyX+fwjLw6Z/1oY5GA9NY061+yPs8LL0BQYkm5r1et3lTIWGo3bJeLIZM4Dsh+VXv1Z8q7oz1PkhSwbmQH19FyQdeohgyzokidbQhGTgk8tO2ol1j2tZMPkwAh3MTRU4Gpmo641Qye69TMhBrhIb5ebmTFXt8HnRbfJT0x/hLjLdCd8hUzo27ICu7yCqZTR74RfIdBvIumSvGQJQ= branches: only: - - /.*/ + - /.*/ diff --git a/CHANGE_HISTORY.md b/CHANGE_HISTORY.md index 3ac84267..31154acf 100644 --- a/CHANGE_HISTORY.md +++ b/CHANGE_HISTORY.md @@ -1,106 +1,90 @@ -## (2024-12-27) - -* re-enable keywords now properly supported (#1031) ([83dac8a](https://github.com/cdimascio/express-openapi-validator/commit/83dac8a)), closes [#1031](https://github.com/cdimascio/express-openapi-validator/issues/1031) -* update deps ([6eb86a6](https://github.com/cdimascio/express-openapi-validator/commit/6eb86a6)) -* v5.4.2 ([c811993](https://github.com/cdimascio/express-openapi-validator/commit/c811993)) - - - -## (2024-12-27) - -* fixes method res with path params (#1032) ([aa60f9c](https://github.com/cdimascio/express-openapi-validator/commit/aa60f9c)), closes [#1032](https://github.com/cdimascio/express-openapi-validator/issues/1032) -* Update README.md ([d43ec2e](https://github.com/cdimascio/express-openapi-validator/commit/d43ec2e)) - - - -## (2024-12-26) - -* update alpha 3.1 version ([cba4aac](https://github.com/cdimascio/express-openapi-validator/commit/cba4aac)) -* v5.3.9 ([75531ae](https://github.com/cdimascio/express-openapi-validator/commit/75531ae)) -* v5.4.0 ([34359d0](https://github.com/cdimascio/express-openapi-validator/commit/34359d0)) -* feat(openapi): support OpenAPI version 3.1 (extends PR #882) (#1027) ([fc876a3](https://github.com/cdimascio/express-openapi-validator/commit/fc876a3)), closes [#882](https://github.com/cdimascio/express-openapi-validator/issues/882) [#1027](https://github.com/cdimascio/express-openapi-validator/issues/1027) [#1009](https://github.com/cdimascio/express-openapi-validator/issues/1009) [#1021](https://github.com/cdimascio/express-openapi-validator/issues/1021) [#1017](https://github.com/cdimascio/express-openapi-validator/issues/1017) [#1016](https://github.com/cdimascio/express-openapi-validator/issues/1016) -* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([8da3707](https://github.com/cdimascio/express-openapi-validator/commit/8da3707)), closes [#1021](https://github.com/cdimascio/express-openapi-validator/issues/1021) -* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([f6e6295](https://github.com/cdimascio/express-openapi-validator/commit/f6e6295)), closes [#972](https://github.com/cdimascio/express-openapi-validator/issues/972) -* fix: fix authHeader without `cookie-parser` middleware (#1003) ([17e91d5](https://github.com/cdimascio/express-openapi-validator/commit/17e91d5)), closes [#1003](https://github.com/cdimascio/express-openapi-validator/issues/1003) [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) -* fix: package.json & package-lock.json to reduce vulnerabilities (#1017) ([e88a4ef](https://github.com/cdimascio/express-openapi-validator/commit/e88a4ef)), closes [#1017](https://github.com/cdimascio/express-openapi-validator/issues/1017) -* fix: upgrade @apidevtools/json-schema-ref-parser from 11.7.0 to 11.7.2 (#1006) ([a67802b](https://github.com/cdimascio/express-openapi-validator/commit/a67802b)), closes [#1006](https://github.com/cdimascio/express-openapi-validator/issues/1006) -* fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#1001) ([7a8fcc0](https://github.com/cdimascio/express-openapi-validator/commit/7a8fcc0)), closes [#1001](https://github.com/cdimascio/express-openapi-validator/issues/1001) -* fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#1008) ([831b648](https://github.com/cdimascio/express-openapi-validator/commit/831b648)), closes [#1008](https://github.com/cdimascio/express-openapi-validator/issues/1008) -* fix: upgrade express-openapi-validator from 5.3.7 to 5.3.8 (#1011) ([65c0e56](https://github.com/cdimascio/express-openapi-validator/commit/65c0e56)), closes [#1011](https://github.com/cdimascio/express-openapi-validator/issues/1011) -* fix: upgrade path-to-regexp from 8.1.0 to 8.2.0 (#1000) ([ed6a9b7](https://github.com/cdimascio/express-openapi-validator/commit/ed6a9b7)), closes [#1000](https://github.com/cdimascio/express-openapi-validator/issues/1000) -* chore(deps): bump cookie and express in /examples/3-eov-operations (#1002) ([f2aba32](https://github.com/cdimascio/express-openapi-validator/commit/f2aba32)), closes [#1002](https://github.com/cdimascio/express-openapi-validator/issues/1002) -* chore(deps): bump path-to-regexp and express in /examples/1-standard (#1016) ([4a3efff](https://github.com/cdimascio/express-openapi-validator/commit/4a3efff)), closes [#1016](https://github.com/cdimascio/express-openapi-validator/issues/1016) - - - -## (2024-10-30) - -* fix: fix authHeader without `cookie-parser` middleware (#1003) ([17e91d5](https://github.com/cdimascio/express-openapi-validator/commit/17e91d5)), closes [#1003](https://github.com/cdimascio/express-openapi-validator/issues/1003) [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) -* chore(deps): bump cookie and express in /examples/3-eov-operations (#1002) ([f2aba32](https://github.com/cdimascio/express-openapi-validator/commit/f2aba32)), closes [#1002](https://github.com/cdimascio/express-openapi-validator/issues/1002) - - - -## (2024-10-26) - -* fix: add cookie support for HTTP bearer authentication (#949) ([00d070b](https://github.com/cdimascio/express-openapi-validator/commit/00d070b)), closes [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) -* fix: examples/1-standard/package.json & examples/1-standard/package-lock.json to reduce vulnerabilit ([8ce7fda](https://github.com/cdimascio/express-openapi-validator/commit/8ce7fda)), closes [#986](https://github.com/cdimascio/express-openapi-validator/issues/986) -* fix: examples/2-standard-multiple-api-specs/package.json & examples/2-standard-multiple-api-specs/pa ([95f5f5a](https://github.com/cdimascio/express-openapi-validator/commit/95f5f5a)), closes [#987](https://github.com/cdimascio/express-openapi-validator/issues/987) -* fix: examples/3-eov-operations/package.json & examples/3-eov-operations/package-lock.json to reduce ([e81222e](https://github.com/cdimascio/express-openapi-validator/commit/e81222e)), closes [#989](https://github.com/cdimascio/express-openapi-validator/issues/989) -* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([263c641](https://github.com/cdimascio/express-openapi-validator/commit/263c641)), closes [#994](https://github.com/cdimascio/express-openapi-validator/issues/994) -* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([e71b5fc](https://github.com/cdimascio/express-openapi-validator/commit/e71b5fc)), closes [#988](https://github.com/cdimascio/express-openapi-validator/issues/988) -* fix: package.json & package-lock.json to reduce vulnerabilities (#993) ([b6201c3](https://github.com/cdimascio/express-openapi-validator/commit/b6201c3)), closes [#993](https://github.com/cdimascio/express-openapi-validator/issues/993) -* fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#995) ([8cee5f9](https://github.com/cdimascio/express-openapi-validator/commit/8cee5f9)), closes [#995](https://github.com/cdimascio/express-openapi-validator/issues/995) -* Create SECURITY.md (#999) ([5e21e3f](https://github.com/cdimascio/express-openapi-validator/commit/5e21e3f)), closes [#999](https://github.com/cdimascio/express-openapi-validator/issues/999) -* example 6 enhancements ([789b43b](https://github.com/cdimascio/express-openapi-validator/commit/789b43b)) -* Update README.md ([946aab8](https://github.com/cdimascio/express-openapi-validator/commit/946aab8)) -* Update README.md ([f61c185](https://github.com/cdimascio/express-openapi-validator/commit/f61c185)) -* chore(deps): bump body-parser and @nestjs/platform-express (#990) ([773f18e](https://github.com/cdimascio/express-openapi-validator/commit/773f18e)), closes [#990](https://github.com/cdimascio/express-openapi-validator/issues/990) -* chore(deps): bump cookie and cookie-parser (#996) ([9bd5177](https://github.com/cdimascio/express-openapi-validator/commit/9bd5177)), closes [#996](https://github.com/cdimascio/express-openapi-validator/issues/996) -* chore(deps): bump path-to-regexp (#997) ([e60d146](https://github.com/cdimascio/express-openapi-validator/commit/e60d146)), closes [#997](https://github.com/cdimascio/express-openapi-validator/issues/997) - - - -## (2024-09-18) - -* fix: upgrade @types/multer from 1.4.11 to 1.4.12 (#983) ([0fa043e](https://github.com/cdimascio/express-openapi-validator/commit/0fa043e)), closes [#983](https://github.com/cdimascio/express-openapi-validator/issues/983) -* feat(path-to-regexp): path-to-regexp 8.1.0 update (#976) ([70cce65](https://github.com/cdimascio/express-openapi-validator/commit/70cce65)), closes [#976](https://github.com/cdimascio/express-openapi-validator/issues/976) - - - -## (2024-09-13) - -* bodyParsers is deprecated so update with expess bodyParsers (#974) ([6dc3b97](https://github.com/cdimascio/express-openapi-validator/commit/6dc3b97)), closes [#974](https://github.com/cdimascio/express-openapi-validator/issues/974) -* Update README.md ([772d1dc](https://github.com/cdimascio/express-openapi-validator/commit/772d1dc)) -* Update README.md ([de4219e](https://github.com/cdimascio/express-openapi-validator/commit/de4219e)) -* fix: upgrade express-openapi-validator from 5.2.0 to 5.3.1 (#960) ([bd636bb](https://github.com/cdimascio/express-openapi-validator/commit/bd636bb)), closes [#960](https://github.com/cdimascio/express-openapi-validator/issues/960) -* chore(deps-dev): bump braces from 3.0.2 to 3.0.3 in /examples/9-nestjs (#964) ([148fa90](https://github.com/cdimascio/express-openapi-validator/commit/148fa90)), closes [#964](https://github.com/cdimascio/express-openapi-validator/issues/964) -* chore(deps-dev): bump braces in /examples/7-response-date-serialization (#963) ([aa3018a](https://github.com/cdimascio/express-openapi-validator/commit/aa3018a)), closes [#963](https://github.com/cdimascio/express-openapi-validator/issues/963) - - - -## (2024-09-06) - -* fix: Dereference path parameters (#962) ([0aebe5d](https://github.com/cdimascio/express-openapi-validator/commit/0aebe5d)), closes [#962](https://github.com/cdimascio/express-openapi-validator/issues/962) -* fix: upgrade express-openapi-validator from 5.2.0 to 5.3.1 (#951) ([5b0058d](https://github.com/cdimascio/express-openapi-validator/commit/5b0058d)), closes [#951](https://github.com/cdimascio/express-openapi-validator/issues/951) -* [StepSecurity] ci: Harden GitHub Actions (#959) ([78e55be](https://github.com/cdimascio/express-openapi-validator/commit/78e55be)), closes [#959](https://github.com/cdimascio/express-openapi-validator/issues/959) -* Fix changelog breaking changes notice (#961) ([0a8dc2f](https://github.com/cdimascio/express-openapi-validator/commit/0a8dc2f)), closes [#961](https://github.com/cdimascio/express-openapi-validator/issues/961) -* update README ([7334ccd](https://github.com/cdimascio/express-openapi-validator/commit/7334ccd)) -* chore(deps-dev): bump braces in /examples/5-custom-operation-resolver (#958) ([eda5612](https://github.com/cdimascio/express-openapi-validator/commit/eda5612)), closes [#958](https://github.com/cdimascio/express-openapi-validator/issues/958) -* chore(deps): bump braces in /examples/4-eov-operations-babel (#957) ([749a8c8](https://github.com/cdimascio/express-openapi-validator/commit/749a8c8)), closes [#957](https://github.com/cdimascio/express-openapi-validator/issues/957) -* chore(deps): bump webpack and @nestjs/cli in /examples/9-nestjs (#953) ([299aad6](https://github.com/cdimascio/express-openapi-validator/commit/299aad6)), closes [#953](https://github.com/cdimascio/express-openapi-validator/issues/953) - - - -## (2024-08-31) - -* Change AJV allErrors default and support user setting (#955) ([392f1dd](https://github.com/cdimascio/express-openapi-validator/commit/392f1dd)), closes [#955](https://github.com/cdimascio/express-openapi-validator/issues/955) [#954](https://github.com/cdimascio/express-openapi-validator/issues/954) -* Update README.md ([f20b1c9](https://github.com/cdimascio/express-openapi-validator/commit/f20b1c9)) -* Use lenient resolver type (#956) ([826ba62](https://github.com/cdimascio/express-openapi-validator/commit/826ba62)), closes [#956](https://github.com/cdimascio/express-openapi-validator/issues/956) [#921](https://github.com/cdimascio/express-openapi-validator/issues/921) [#952](https://github.com/cdimascio/express-openapi-validator/issues/952) - +## (2024-12-27) + +- re-enable keywords now properly supported (#1031) ([83dac8a](https://github.com/cdimascio/express-openapi-validator/commit/83dac8a)), closes [#1031](https://github.com/cdimascio/express-openapi-validator/issues/1031) +- update deps ([6eb86a6](https://github.com/cdimascio/express-openapi-validator/commit/6eb86a6)) +- v5.4.2 ([c811993](https://github.com/cdimascio/express-openapi-validator/commit/c811993)) + +## (2024-12-27) + +- fixes method res with path params (#1032) ([aa60f9c](https://github.com/cdimascio/express-openapi-validator/commit/aa60f9c)), closes [#1032](https://github.com/cdimascio/express-openapi-validator/issues/1032) +- Update README.md ([d43ec2e](https://github.com/cdimascio/express-openapi-validator/commit/d43ec2e)) + +## (2024-12-26) + +- update alpha 3.1 version ([cba4aac](https://github.com/cdimascio/express-openapi-validator/commit/cba4aac)) +- v5.3.9 ([75531ae](https://github.com/cdimascio/express-openapi-validator/commit/75531ae)) +- v5.4.0 ([34359d0](https://github.com/cdimascio/express-openapi-validator/commit/34359d0)) +- feat(openapi): support OpenAPI version 3.1 (extends PR #882) (#1027) ([fc876a3](https://github.com/cdimascio/express-openapi-validator/commit/fc876a3)), closes [#882](https://github.com/cdimascio/express-openapi-validator/issues/882) [#1027](https://github.com/cdimascio/express-openapi-validator/issues/1027) [#1009](https://github.com/cdimascio/express-openapi-validator/issues/1009) [#1021](https://github.com/cdimascio/express-openapi-validator/issues/1021) [#1017](https://github.com/cdimascio/express-openapi-validator/issues/1017) [#1016](https://github.com/cdimascio/express-openapi-validator/issues/1016) +- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([8da3707](https://github.com/cdimascio/express-openapi-validator/commit/8da3707)), closes [#1021](https://github.com/cdimascio/express-openapi-validator/issues/1021) +- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([f6e6295](https://github.com/cdimascio/express-openapi-validator/commit/f6e6295)), closes [#972](https://github.com/cdimascio/express-openapi-validator/issues/972) +- fix: fix authHeader without `cookie-parser` middleware (#1003) ([17e91d5](https://github.com/cdimascio/express-openapi-validator/commit/17e91d5)), closes [#1003](https://github.com/cdimascio/express-openapi-validator/issues/1003) [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) +- fix: package.json & package-lock.json to reduce vulnerabilities (#1017) ([e88a4ef](https://github.com/cdimascio/express-openapi-validator/commit/e88a4ef)), closes [#1017](https://github.com/cdimascio/express-openapi-validator/issues/1017) +- fix: upgrade @apidevtools/json-schema-ref-parser from 11.7.0 to 11.7.2 (#1006) ([a67802b](https://github.com/cdimascio/express-openapi-validator/commit/a67802b)), closes [#1006](https://github.com/cdimascio/express-openapi-validator/issues/1006) +- fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#1001) ([7a8fcc0](https://github.com/cdimascio/express-openapi-validator/commit/7a8fcc0)), closes [#1001](https://github.com/cdimascio/express-openapi-validator/issues/1001) +- fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#1008) ([831b648](https://github.com/cdimascio/express-openapi-validator/commit/831b648)), closes [#1008](https://github.com/cdimascio/express-openapi-validator/issues/1008) +- fix: upgrade express-openapi-validator from 5.3.7 to 5.3.8 (#1011) ([65c0e56](https://github.com/cdimascio/express-openapi-validator/commit/65c0e56)), closes [#1011](https://github.com/cdimascio/express-openapi-validator/issues/1011) +- fix: upgrade path-to-regexp from 8.1.0 to 8.2.0 (#1000) ([ed6a9b7](https://github.com/cdimascio/express-openapi-validator/commit/ed6a9b7)), closes [#1000](https://github.com/cdimascio/express-openapi-validator/issues/1000) +- chore(deps): bump cookie and express in /examples/3-eov-operations (#1002) ([f2aba32](https://github.com/cdimascio/express-openapi-validator/commit/f2aba32)), closes [#1002](https://github.com/cdimascio/express-openapi-validator/issues/1002) +- chore(deps): bump path-to-regexp and express in /examples/1-standard (#1016) ([4a3efff](https://github.com/cdimascio/express-openapi-validator/commit/4a3efff)), closes [#1016](https://github.com/cdimascio/express-openapi-validator/issues/1016) + +## (2024-10-30) + +- fix: fix authHeader without `cookie-parser` middleware (#1003) ([17e91d5](https://github.com/cdimascio/express-openapi-validator/commit/17e91d5)), closes [#1003](https://github.com/cdimascio/express-openapi-validator/issues/1003) [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) +- chore(deps): bump cookie and express in /examples/3-eov-operations (#1002) ([f2aba32](https://github.com/cdimascio/express-openapi-validator/commit/f2aba32)), closes [#1002](https://github.com/cdimascio/express-openapi-validator/issues/1002) + +## (2024-10-26) + +- fix: add cookie support for HTTP bearer authentication (#949) ([00d070b](https://github.com/cdimascio/express-openapi-validator/commit/00d070b)), closes [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) +- fix: examples/1-standard/package.json & examples/1-standard/package-lock.json to reduce vulnerabilit ([8ce7fda](https://github.com/cdimascio/express-openapi-validator/commit/8ce7fda)), closes [#986](https://github.com/cdimascio/express-openapi-validator/issues/986) +- fix: examples/2-standard-multiple-api-specs/package.json & examples/2-standard-multiple-api-specs/pa ([95f5f5a](https://github.com/cdimascio/express-openapi-validator/commit/95f5f5a)), closes [#987](https://github.com/cdimascio/express-openapi-validator/issues/987) +- fix: examples/3-eov-operations/package.json & examples/3-eov-operations/package-lock.json to reduce ([e81222e](https://github.com/cdimascio/express-openapi-validator/commit/e81222e)), closes [#989](https://github.com/cdimascio/express-openapi-validator/issues/989) +- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([263c641](https://github.com/cdimascio/express-openapi-validator/commit/263c641)), closes [#994](https://github.com/cdimascio/express-openapi-validator/issues/994) +- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([e71b5fc](https://github.com/cdimascio/express-openapi-validator/commit/e71b5fc)), closes [#988](https://github.com/cdimascio/express-openapi-validator/issues/988) +- fix: package.json & package-lock.json to reduce vulnerabilities (#993) ([b6201c3](https://github.com/cdimascio/express-openapi-validator/commit/b6201c3)), closes [#993](https://github.com/cdimascio/express-openapi-validator/issues/993) +- fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#995) ([8cee5f9](https://github.com/cdimascio/express-openapi-validator/commit/8cee5f9)), closes [#995](https://github.com/cdimascio/express-openapi-validator/issues/995) +- Create SECURITY.md (#999) ([5e21e3f](https://github.com/cdimascio/express-openapi-validator/commit/5e21e3f)), closes [#999](https://github.com/cdimascio/express-openapi-validator/issues/999) +- example 6 enhancements ([789b43b](https://github.com/cdimascio/express-openapi-validator/commit/789b43b)) +- Update README.md ([946aab8](https://github.com/cdimascio/express-openapi-validator/commit/946aab8)) +- Update README.md ([f61c185](https://github.com/cdimascio/express-openapi-validator/commit/f61c185)) +- chore(deps): bump body-parser and @nestjs/platform-express (#990) ([773f18e](https://github.com/cdimascio/express-openapi-validator/commit/773f18e)), closes [#990](https://github.com/cdimascio/express-openapi-validator/issues/990) +- chore(deps): bump cookie and cookie-parser (#996) ([9bd5177](https://github.com/cdimascio/express-openapi-validator/commit/9bd5177)), closes [#996](https://github.com/cdimascio/express-openapi-validator/issues/996) +- chore(deps): bump path-to-regexp (#997) ([e60d146](https://github.com/cdimascio/express-openapi-validator/commit/e60d146)), closes [#997](https://github.com/cdimascio/express-openapi-validator/issues/997) + +## (2024-09-18) + +- fix: upgrade @types/multer from 1.4.11 to 1.4.12 (#983) ([0fa043e](https://github.com/cdimascio/express-openapi-validator/commit/0fa043e)), closes [#983](https://github.com/cdimascio/express-openapi-validator/issues/983) +- feat(path-to-regexp): path-to-regexp 8.1.0 update (#976) ([70cce65](https://github.com/cdimascio/express-openapi-validator/commit/70cce65)), closes [#976](https://github.com/cdimascio/express-openapi-validator/issues/976) + +## (2024-09-13) + +- bodyParsers is deprecated so update with expess bodyParsers (#974) ([6dc3b97](https://github.com/cdimascio/express-openapi-validator/commit/6dc3b97)), closes [#974](https://github.com/cdimascio/express-openapi-validator/issues/974) +- Update README.md ([772d1dc](https://github.com/cdimascio/express-openapi-validator/commit/772d1dc)) +- Update README.md ([de4219e](https://github.com/cdimascio/express-openapi-validator/commit/de4219e)) +- fix: upgrade express-openapi-validator from 5.2.0 to 5.3.1 (#960) ([bd636bb](https://github.com/cdimascio/express-openapi-validator/commit/bd636bb)), closes [#960](https://github.com/cdimascio/express-openapi-validator/issues/960) +- chore(deps-dev): bump braces from 3.0.2 to 3.0.3 in /examples/9-nestjs (#964) ([148fa90](https://github.com/cdimascio/express-openapi-validator/commit/148fa90)), closes [#964](https://github.com/cdimascio/express-openapi-validator/issues/964) +- chore(deps-dev): bump braces in /examples/7-response-date-serialization (#963) ([aa3018a](https://github.com/cdimascio/express-openapi-validator/commit/aa3018a)), closes [#963](https://github.com/cdimascio/express-openapi-validator/issues/963) + +## (2024-09-06) + +- fix: Dereference path parameters (#962) ([0aebe5d](https://github.com/cdimascio/express-openapi-validator/commit/0aebe5d)), closes [#962](https://github.com/cdimascio/express-openapi-validator/issues/962) +- fix: upgrade express-openapi-validator from 5.2.0 to 5.3.1 (#951) ([5b0058d](https://github.com/cdimascio/express-openapi-validator/commit/5b0058d)), closes [#951](https://github.com/cdimascio/express-openapi-validator/issues/951) +- [StepSecurity] ci: Harden GitHub Actions (#959) ([78e55be](https://github.com/cdimascio/express-openapi-validator/commit/78e55be)), closes [#959](https://github.com/cdimascio/express-openapi-validator/issues/959) +- Fix changelog breaking changes notice (#961) ([0a8dc2f](https://github.com/cdimascio/express-openapi-validator/commit/0a8dc2f)), closes [#961](https://github.com/cdimascio/express-openapi-validator/issues/961) +- update README ([7334ccd](https://github.com/cdimascio/express-openapi-validator/commit/7334ccd)) +- chore(deps-dev): bump braces in /examples/5-custom-operation-resolver (#958) ([eda5612](https://github.com/cdimascio/express-openapi-validator/commit/eda5612)), closes [#958](https://github.com/cdimascio/express-openapi-validator/issues/958) +- chore(deps): bump braces in /examples/4-eov-operations-babel (#957) ([749a8c8](https://github.com/cdimascio/express-openapi-validator/commit/749a8c8)), closes [#957](https://github.com/cdimascio/express-openapi-validator/issues/957) +- chore(deps): bump webpack and @nestjs/cli in /examples/9-nestjs (#953) ([299aad6](https://github.com/cdimascio/express-openapi-validator/commit/299aad6)), closes [#953](https://github.com/cdimascio/express-openapi-validator/issues/953) + +## (2024-08-31) + +- Change AJV allErrors default and support user setting (#955) ([392f1dd](https://github.com/cdimascio/express-openapi-validator/commit/392f1dd)), closes [#955](https://github.com/cdimascio/express-openapi-validator/issues/955) [#954](https://github.com/cdimascio/express-openapi-validator/issues/954) +- Update README.md ([f20b1c9](https://github.com/cdimascio/express-openapi-validator/commit/f20b1c9)) +- Use lenient resolver type (#956) ([826ba62](https://github.com/cdimascio/express-openapi-validator/commit/826ba62)), closes [#956](https://github.com/cdimascio/express-openapi-validator/issues/956) [#921](https://github.com/cdimascio/express-openapi-validator/issues/921) [#952](https://github.com/cdimascio/express-openapi-validator/issues/952) ### breaking change By default, request and response validation now stops after the first failure. Only one error will be reported even when multiple may exist. This follows best practices from AJV: + - [Security risks of trusted schemas](https://ajv.js.org/security.html#security-risks-of-trusted-schemas) - [`allErrors` option](https://ajv.js.org/options.html#allerrors) @@ -116,251 +100,211 @@ app.use( validateResponses: { allErrors: true, }, - }) + }), ); ``` - -## (2024-08-24) - -* chore(deps-dev): bump @babel/traverse in /examples/9-nestjs (#948) ([edd054f](https://github.com/cdimascio/express-openapi-validator/commit/edd054f)), closes [#948](https://github.com/cdimascio/express-openapi-validator/issues/948) -* chore(deps-dev): bump braces in /examples/8-top-level-discriminator (#929) ([e3a9526](https://github.com/cdimascio/express-openapi-validator/commit/e3a9526)), closes [#929](https://github.com/cdimascio/express-openapi-validator/issues/929) -* chore(deps-dev): bump ws from 7.5.5 to 7.5.10 in /examples/9-nestjs (#930) ([9d5895b](https://github.com/cdimascio/express-openapi-validator/commit/9d5895b)), closes [#930](https://github.com/cdimascio/express-openapi-validator/issues/930) -* fix: correct security schema logic for OR verification (#946) ([2265a10](https://github.com/cdimascio/express-openapi-validator/commit/2265a10)), closes [#946](https://github.com/cdimascio/express-openapi-validator/issues/946) -* fix: upgrade @apidevtools/json-schema-ref-parser from 11.6.4 to 11.7.0 (#947) ([ea4129c](https://github.com/cdimascio/express-openapi-validator/commit/ea4129c)), closes [#947](https://github.com/cdimascio/express-openapi-validator/issues/947) -* fix: upgrade ajv from 8.15.0 to 8.17.1 (#945) ([087d8f7](https://github.com/cdimascio/express-openapi-validator/commit/087d8f7)), closes [#945](https://github.com/cdimascio/express-openapi-validator/issues/945) -* fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#944) ([f022d21](https://github.com/cdimascio/express-openapi-validator/commit/f022d21)), closes [#944](https://github.com/cdimascio/express-openapi-validator/issues/944) -* version 5.3.2 ([4428922](https://github.com/cdimascio/express-openapi-validator/commit/4428922)) - - - -## (2024-08-24) - -* fix: correct security schema logic for OR verification (#946) ([2265a10](https://github.com/cdimascio/express-openapi-validator/commit/2265a10)), closes [#946](https://github.com/cdimascio/express-openapi-validator/issues/946) -* fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#944) ([f022d21](https://github.com/cdimascio/express-openapi-validator/commit/f022d21)), closes [#944](https://github.com/cdimascio/express-openapi-validator/issues/944) - - - -## (2024-08-05) - -* Stripped query params for req.url branch arm (#942) ([26d06c4](https://github.com/cdimascio/express-openapi-validator/commit/26d06c4)), closes [#942](https://github.com/cdimascio/express-openapi-validator/issues/942) -* Update LICENSE ([20727ff](https://github.com/cdimascio/express-openapi-validator/commit/20727ff)) -* version 5.2.1 ([aace73c](https://github.com/cdimascio/express-openapi-validator/commit/aace73c)) -* FIX: issue #917 (#935) ([8e66d3f](https://github.com/cdimascio/express-openapi-validator/commit/8e66d3f)), closes [#917](https://github.com/cdimascio/express-openapi-validator/issues/917) [#935](https://github.com/cdimascio/express-openapi-validator/issues/935) -* fix: upgrade @apidevtools/json-schema-ref-parser from 11.6.2 to 11.6.4 (#937) ([f148eeb](https://github.com/cdimascio/express-openapi-validator/commit/f148eeb)), closes [#937](https://github.com/cdimascio/express-openapi-validator/issues/937) -* fix: upgrade ajv from 8.14.0 to 8.15.0 (#938) ([a1ea81f](https://github.com/cdimascio/express-openapi-validator/commit/a1ea81f)), closes [#938](https://github.com/cdimascio/express-openapi-validator/issues/938) -* fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#936) ([2d75db4](https://github.com/cdimascio/express-openapi-validator/commit/2d75db4)), closes [#936](https://github.com/cdimascio/express-openapi-validator/issues/936) -* chore(deps-dev): bump braces from 3.0.2 to 3.0.3 (#928) ([093bd3c](https://github.com/cdimascio/express-openapi-validator/commit/093bd3c)), closes [#928](https://github.com/cdimascio/express-openapi-validator/issues/928) - - - -## (2024-06-02) - -* Add `express` as peer dependency (#907) ([4e8bc84](https://github.com/cdimascio/express-openapi-validator/commit/4e8bc84)), closes [#907](https://github.com/cdimascio/express-openapi-validator/issues/907) -* Add multipart fix when does not exist any body (#905) ([5c98d17](https://github.com/cdimascio/express-openapi-validator/commit/5c98d17)), closes [#905](https://github.com/cdimascio/express-openapi-validator/issues/905) -* add reponse serializer tests for arrays ([bbbd160](https://github.com/cdimascio/express-openapi-validator/commit/bbbd160)) -* pass coerceTypes through (#809) ([8f7c678](https://github.com/cdimascio/express-openapi-validator/commit/8f7c678)), closes [#809](https://github.com/cdimascio/express-openapi-validator/issues/809) -* Support async operation handler resolver (#921) ([a4a7175](https://github.com/cdimascio/express-openapi-validator/commit/a4a7175)), closes [#921](https://github.com/cdimascio/express-openapi-validator/issues/921) -* upgrade ajv ([a708132](https://github.com/cdimascio/express-openapi-validator/commit/a708132)) -* upgrade example 3 ([43cccc8](https://github.com/cdimascio/express-openapi-validator/commit/43cccc8)) -* upgrade example 4 ([255f20f](https://github.com/cdimascio/express-openapi-validator/commit/255f20f)) -* v5.2.0 ([42cb3ab](https://github.com/cdimascio/express-openapi-validator/commit/42cb3ab)) -* chore: apiSpec may be const literal (#854) ([e35a07c](https://github.com/cdimascio/express-openapi-validator/commit/e35a07c)), closes [#854](https://github.com/cdimascio/express-openapi-validator/issues/854) -* chore(dependencies): bump @apidevtools/json-schema-ref-parser to 11.6.2 to prevent vulnerability (#9 ([61ff0cf](https://github.com/cdimascio/express-openapi-validator/commit/61ff0cf)), closes [#918](https://github.com/cdimascio/express-openapi-validator/issues/918) -* chore(deps-dev): bump @babel/traverse (#924) ([5a04ea9](https://github.com/cdimascio/express-openapi-validator/commit/5a04ea9)), closes [#924](https://github.com/cdimascio/express-openapi-validator/issues/924) -* chore(deps): bump axios, @nestjs/common, @nestjs/core, @nestjs/platform-express and @nestjs/testing ([b77150f](https://github.com/cdimascio/express-openapi-validator/commit/b77150f)), closes [#925](https://github.com/cdimascio/express-openapi-validator/issues/925) -* chore(deps): bump webpack and @nestjs/cli in /examples/9-nestjs (#831) ([c0c5f4c](https://github.com/cdimascio/express-openapi-validator/commit/c0c5f4c)), closes [#831](https://github.com/cdimascio/express-openapi-validator/issues/831) -* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([87d173b](https://github.com/cdimascio/express-openapi-validator/commit/87d173b)), closes [#911](https://github.com/cdimascio/express-openapi-validator/issues/911) -* fix: package.json & package-lock.json to reduce vulnerabilities (#920) ([898ceb7](https://github.com/cdimascio/express-openapi-validator/commit/898ceb7)), closes [#920](https://github.com/cdimascio/express-openapi-validator/issues/920) -* fix: upgrade @types/multer from 1.4.7 to 1.4.11 (#897) ([a7d67e7](https://github.com/cdimascio/express-openapi-validator/commit/a7d67e7)), closes [#897](https://github.com/cdimascio/express-openapi-validator/issues/897) -* fix: upgrade path-to-regexp from 6.2.0 to 6.2.2 (#914) ([bce2d6a](https://github.com/cdimascio/express-openapi-validator/commit/bce2d6a)), closes [#914](https://github.com/cdimascio/express-openapi-validator/issues/914) - - +## (2024-08-24) + +- chore(deps-dev): bump @babel/traverse in /examples/9-nestjs (#948) ([edd054f](https://github.com/cdimascio/express-openapi-validator/commit/edd054f)), closes [#948](https://github.com/cdimascio/express-openapi-validator/issues/948) +- chore(deps-dev): bump braces in /examples/8-top-level-discriminator (#929) ([e3a9526](https://github.com/cdimascio/express-openapi-validator/commit/e3a9526)), closes [#929](https://github.com/cdimascio/express-openapi-validator/issues/929) +- chore(deps-dev): bump ws from 7.5.5 to 7.5.10 in /examples/9-nestjs (#930) ([9d5895b](https://github.com/cdimascio/express-openapi-validator/commit/9d5895b)), closes [#930](https://github.com/cdimascio/express-openapi-validator/issues/930) +- fix: correct security schema logic for OR verification (#946) ([2265a10](https://github.com/cdimascio/express-openapi-validator/commit/2265a10)), closes [#946](https://github.com/cdimascio/express-openapi-validator/issues/946) +- fix: upgrade @apidevtools/json-schema-ref-parser from 11.6.4 to 11.7.0 (#947) ([ea4129c](https://github.com/cdimascio/express-openapi-validator/commit/ea4129c)), closes [#947](https://github.com/cdimascio/express-openapi-validator/issues/947) +- fix: upgrade ajv from 8.15.0 to 8.17.1 (#945) ([087d8f7](https://github.com/cdimascio/express-openapi-validator/commit/087d8f7)), closes [#945](https://github.com/cdimascio/express-openapi-validator/issues/945) +- fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#944) ([f022d21](https://github.com/cdimascio/express-openapi-validator/commit/f022d21)), closes [#944](https://github.com/cdimascio/express-openapi-validator/issues/944) +- version 5.3.2 ([4428922](https://github.com/cdimascio/express-openapi-validator/commit/4428922)) + +## (2024-08-24) + +- fix: correct security schema logic for OR verification (#946) ([2265a10](https://github.com/cdimascio/express-openapi-validator/commit/2265a10)), closes [#946](https://github.com/cdimascio/express-openapi-validator/issues/946) +- fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#944) ([f022d21](https://github.com/cdimascio/express-openapi-validator/commit/f022d21)), closes [#944](https://github.com/cdimascio/express-openapi-validator/issues/944) + +## (2024-08-05) + +- Stripped query params for req.url branch arm (#942) ([26d06c4](https://github.com/cdimascio/express-openapi-validator/commit/26d06c4)), closes [#942](https://github.com/cdimascio/express-openapi-validator/issues/942) +- Update LICENSE ([20727ff](https://github.com/cdimascio/express-openapi-validator/commit/20727ff)) +- version 5.2.1 ([aace73c](https://github.com/cdimascio/express-openapi-validator/commit/aace73c)) +- FIX: issue #917 (#935) ([8e66d3f](https://github.com/cdimascio/express-openapi-validator/commit/8e66d3f)), closes [#917](https://github.com/cdimascio/express-openapi-validator/issues/917) [#935](https://github.com/cdimascio/express-openapi-validator/issues/935) +- fix: upgrade @apidevtools/json-schema-ref-parser from 11.6.2 to 11.6.4 (#937) ([f148eeb](https://github.com/cdimascio/express-openapi-validator/commit/f148eeb)), closes [#937](https://github.com/cdimascio/express-openapi-validator/issues/937) +- fix: upgrade ajv from 8.14.0 to 8.15.0 (#938) ([a1ea81f](https://github.com/cdimascio/express-openapi-validator/commit/a1ea81f)), closes [#938](https://github.com/cdimascio/express-openapi-validator/issues/938) +- fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#936) ([2d75db4](https://github.com/cdimascio/express-openapi-validator/commit/2d75db4)), closes [#936](https://github.com/cdimascio/express-openapi-validator/issues/936) +- chore(deps-dev): bump braces from 3.0.2 to 3.0.3 (#928) ([093bd3c](https://github.com/cdimascio/express-openapi-validator/commit/093bd3c)), closes [#928](https://github.com/cdimascio/express-openapi-validator/issues/928) + +## (2024-06-02) + +- Add `express` as peer dependency (#907) ([4e8bc84](https://github.com/cdimascio/express-openapi-validator/commit/4e8bc84)), closes [#907](https://github.com/cdimascio/express-openapi-validator/issues/907) +- Add multipart fix when does not exist any body (#905) ([5c98d17](https://github.com/cdimascio/express-openapi-validator/commit/5c98d17)), closes [#905](https://github.com/cdimascio/express-openapi-validator/issues/905) +- add reponse serializer tests for arrays ([bbbd160](https://github.com/cdimascio/express-openapi-validator/commit/bbbd160)) +- pass coerceTypes through (#809) ([8f7c678](https://github.com/cdimascio/express-openapi-validator/commit/8f7c678)), closes [#809](https://github.com/cdimascio/express-openapi-validator/issues/809) +- Support async operation handler resolver (#921) ([a4a7175](https://github.com/cdimascio/express-openapi-validator/commit/a4a7175)), closes [#921](https://github.com/cdimascio/express-openapi-validator/issues/921) +- upgrade ajv ([a708132](https://github.com/cdimascio/express-openapi-validator/commit/a708132)) +- upgrade example 3 ([43cccc8](https://github.com/cdimascio/express-openapi-validator/commit/43cccc8)) +- upgrade example 4 ([255f20f](https://github.com/cdimascio/express-openapi-validator/commit/255f20f)) +- v5.2.0 ([42cb3ab](https://github.com/cdimascio/express-openapi-validator/commit/42cb3ab)) +- chore: apiSpec may be const literal (#854) ([e35a07c](https://github.com/cdimascio/express-openapi-validator/commit/e35a07c)), closes [#854](https://github.com/cdimascio/express-openapi-validator/issues/854) +- chore(dependencies): bump @apidevtools/json-schema-ref-parser to 11.6.2 to prevent vulnerability (#9 ([61ff0cf](https://github.com/cdimascio/express-openapi-validator/commit/61ff0cf)), closes [#918](https://github.com/cdimascio/express-openapi-validator/issues/918) +- chore(deps-dev): bump @babel/traverse (#924) ([5a04ea9](https://github.com/cdimascio/express-openapi-validator/commit/5a04ea9)), closes [#924](https://github.com/cdimascio/express-openapi-validator/issues/924) +- chore(deps): bump axios, @nestjs/common, @nestjs/core, @nestjs/platform-express and @nestjs/testing ([b77150f](https://github.com/cdimascio/express-openapi-validator/commit/b77150f)), closes [#925](https://github.com/cdimascio/express-openapi-validator/issues/925) +- chore(deps): bump webpack and @nestjs/cli in /examples/9-nestjs (#831) ([c0c5f4c](https://github.com/cdimascio/express-openapi-validator/commit/c0c5f4c)), closes [#831](https://github.com/cdimascio/express-openapi-validator/issues/831) +- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([87d173b](https://github.com/cdimascio/express-openapi-validator/commit/87d173b)), closes [#911](https://github.com/cdimascio/express-openapi-validator/issues/911) +- fix: package.json & package-lock.json to reduce vulnerabilities (#920) ([898ceb7](https://github.com/cdimascio/express-openapi-validator/commit/898ceb7)), closes [#920](https://github.com/cdimascio/express-openapi-validator/issues/920) +- fix: upgrade @types/multer from 1.4.7 to 1.4.11 (#897) ([a7d67e7](https://github.com/cdimascio/express-openapi-validator/commit/a7d67e7)), closes [#897](https://github.com/cdimascio/express-openapi-validator/issues/897) +- fix: upgrade path-to-regexp from 6.2.0 to 6.2.2 (#914) ([bce2d6a](https://github.com/cdimascio/express-openapi-validator/commit/bce2d6a)), closes [#914](https://github.com/cdimascio/express-openapi-validator/issues/914) ## 5.1.6 (2024-02-11) -* Fixes for 881 - multiple specs w/validateRequests fail (#903) ([766806b](https://github.com/cdimascio/express-openapi-validator/commit/766806b)), closes [#903](https://github.com/cdimascio/express-openapi-validator/issues/903) - - +- Fixes for 881 - multiple specs w/validateRequests fail (#903) ([766806b](https://github.com/cdimascio/express-openapi-validator/commit/766806b)), closes [#903](https://github.com/cdimascio/express-openapi-validator/issues/903) ## 5.1.5 (2024-02-10) -* fixes write-only tests ([8c53e58](https://github.com/cdimascio/express-openapi-validator/commit/8c53e58)) -* Support writeOnly + required combination #149 (#756) ([4f16ed2](https://github.com/cdimascio/express-openapi-validator/commit/4f16ed2)), closes [#149](https://github.com/cdimascio/express-openapi-validator/issues/149) [#756](https://github.com/cdimascio/express-openapi-validator/issues/756) -* v5.1.5 ([708f2f5](https://github.com/cdimascio/express-openapi-validator/commit/708f2f5)) - - +- fixes write-only tests ([8c53e58](https://github.com/cdimascio/express-openapi-validator/commit/8c53e58)) +- Support writeOnly + required combination #149 (#756) ([4f16ed2](https://github.com/cdimascio/express-openapi-validator/commit/4f16ed2)), closes [#149](https://github.com/cdimascio/express-openapi-validator/issues/149) [#756](https://github.com/cdimascio/express-openapi-validator/issues/756) +- v5.1.5 ([708f2f5](https://github.com/cdimascio/express-openapi-validator/commit/708f2f5)) ## 5.1.4 (2024-02-09) -* add cookies to examples 1 and 2 (#891) ([2c95d5b](https://github.com/cdimascio/express-openapi-validator/commit/2c95d5b)), closes [#891](https://github.com/cdimascio/express-openapi-validator/issues/891) -* Direct example broken link to the guide ([00a9c8f](https://github.com/cdimascio/express-openapi-validator/commit/00a9c8f)) -* fixes badging for build and test ([631fb7b](https://github.com/cdimascio/express-openapi-validator/commit/631fb7b)) -* npm audit fix (#892) ([2977c0a](https://github.com/cdimascio/express-openapi-validator/commit/2977c0a)), closes [#892](https://github.com/cdimascio/express-openapi-validator/issues/892) -* Remove read only and write only fields (#895) ([97617fd](https://github.com/cdimascio/express-openapi-validator/commit/97617fd)), closes [#895](https://github.com/cdimascio/express-openapi-validator/issues/895) [#627](https://github.com/cdimascio/express-openapi-validator/issues/627) -* removes lodash.uniq and lodash.zipobject dependencies (#893) ([1206802](https://github.com/cdimascio/express-openapi-validator/commit/1206802)), closes [#893](https://github.com/cdimascio/express-openapi-validator/issues/893) -* Update CONTRIBUTING.md ([6d67169](https://github.com/cdimascio/express-openapi-validator/commit/6d67169)) -* Update README.md ([dffda28](https://github.com/cdimascio/express-openapi-validator/commit/dffda28)) -* Update README.md ([bdd0d79](https://github.com/cdimascio/express-openapi-validator/commit/bdd0d79)) -* Update README.md (#896) ([bb66916](https://github.com/cdimascio/express-openapi-validator/commit/bb66916)), closes [#896](https://github.com/cdimascio/express-openapi-validator/issues/896) -* v5.1.4 ([b3d7483](https://github.com/cdimascio/express-openapi-validator/commit/b3d7483)) -* v5.1.4 ([509fa22](https://github.com/cdimascio/express-openapi-validator/commit/509fa22)) -* fix: #887 allow multiple params with wildcard (#898) ([2d33d0a](https://github.com/cdimascio/express-openapi-validator/commit/2d33d0a)), closes [#887](https://github.com/cdimascio/express-openapi-validator/issues/887) [#898](https://github.com/cdimascio/express-openapi-validator/issues/898) [#1](https://github.com/cdimascio/express-openapi-validator/issues/1) -* docs: fix doc typo in README.md (#885) ([8a81bf8](https://github.com/cdimascio/express-openapi-validator/commit/8a81bf8)), closes [#885](https://github.com/cdimascio/express-openapi-validator/issues/885) - - +- add cookies to examples 1 and 2 (#891) ([2c95d5b](https://github.com/cdimascio/express-openapi-validator/commit/2c95d5b)), closes [#891](https://github.com/cdimascio/express-openapi-validator/issues/891) +- Direct example broken link to the guide ([00a9c8f](https://github.com/cdimascio/express-openapi-validator/commit/00a9c8f)) +- fixes badging for build and test ([631fb7b](https://github.com/cdimascio/express-openapi-validator/commit/631fb7b)) +- npm audit fix (#892) ([2977c0a](https://github.com/cdimascio/express-openapi-validator/commit/2977c0a)), closes [#892](https://github.com/cdimascio/express-openapi-validator/issues/892) +- Remove read only and write only fields (#895) ([97617fd](https://github.com/cdimascio/express-openapi-validator/commit/97617fd)), closes [#895](https://github.com/cdimascio/express-openapi-validator/issues/895) [#627](https://github.com/cdimascio/express-openapi-validator/issues/627) +- removes lodash.uniq and lodash.zipobject dependencies (#893) ([1206802](https://github.com/cdimascio/express-openapi-validator/commit/1206802)), closes [#893](https://github.com/cdimascio/express-openapi-validator/issues/893) +- Update CONTRIBUTING.md ([6d67169](https://github.com/cdimascio/express-openapi-validator/commit/6d67169)) +- Update README.md ([dffda28](https://github.com/cdimascio/express-openapi-validator/commit/dffda28)) +- Update README.md ([bdd0d79](https://github.com/cdimascio/express-openapi-validator/commit/bdd0d79)) +- Update README.md (#896) ([bb66916](https://github.com/cdimascio/express-openapi-validator/commit/bb66916)), closes [#896](https://github.com/cdimascio/express-openapi-validator/issues/896) +- v5.1.4 ([b3d7483](https://github.com/cdimascio/express-openapi-validator/commit/b3d7483)) +- v5.1.4 ([509fa22](https://github.com/cdimascio/express-openapi-validator/commit/509fa22)) +- fix: #887 allow multiple params with wildcard (#898) ([2d33d0a](https://github.com/cdimascio/express-openapi-validator/commit/2d33d0a)), closes [#887](https://github.com/cdimascio/express-openapi-validator/issues/887) [#898](https://github.com/cdimascio/express-openapi-validator/issues/898) [#1](https://github.com/cdimascio/express-openapi-validator/issues/1) +- docs: fix doc typo in README.md (#885) ([8a81bf8](https://github.com/cdimascio/express-openapi-validator/commit/8a81bf8)), closes [#885](https://github.com/cdimascio/express-openapi-validator/issues/885) ## 5.1.3 (2024-01-27) -* CLS Context is lost after using multer middleware (#695) ([40716fb](https://github.com/cdimascio/express-openapi-validator/commit/40716fb)), closes [#695](https://github.com/cdimascio/express-openapi-validator/issues/695) -* remove examples from schema (#890) ([0ad49ec](https://github.com/cdimascio/express-openapi-validator/commit/0ad49ec)), closes [#890](https://github.com/cdimascio/express-openapi-validator/issues/890) -* v5.1.3 ([f806690](https://github.com/cdimascio/express-openapi-validator/commit/f806690)) -* v5.1.3 ([e567701](https://github.com/cdimascio/express-openapi-validator/commit/e567701)) - - +- CLS Context is lost after using multer middleware (#695) ([40716fb](https://github.com/cdimascio/express-openapi-validator/commit/40716fb)), closes [#695](https://github.com/cdimascio/express-openapi-validator/issues/695) +- remove examples from schema (#890) ([0ad49ec](https://github.com/cdimascio/express-openapi-validator/commit/0ad49ec)), closes [#890](https://github.com/cdimascio/express-openapi-validator/issues/890) +- v5.1.3 ([f806690](https://github.com/cdimascio/express-openapi-validator/commit/f806690)) +- v5.1.3 ([e567701](https://github.com/cdimascio/express-openapi-validator/commit/e567701)) ## 5.1.2 (2023-12-04) -* Normalize request body ContentTypes (#863) ([0099b0d](https://github.com/cdimascio/express-openapi-validator/commit/0099b0d)), closes [#863](https://github.com/cdimascio/express-openapi-validator/issues/863) -* Safer handling of multipart nested JSON body props (#878) ([807e09c](https://github.com/cdimascio/express-openapi-validator/commit/807e09c)), closes [#878](https://github.com/cdimascio/express-openapi-validator/issues/878) -* v5.1.1 ([4b0c989](https://github.com/cdimascio/express-openapi-validator/commit/4b0c989)) - - +- Normalize request body ContentTypes (#863) ([0099b0d](https://github.com/cdimascio/express-openapi-validator/commit/0099b0d)), closes [#863](https://github.com/cdimascio/express-openapi-validator/issues/863) +- Safer handling of multipart nested JSON body props (#878) ([807e09c](https://github.com/cdimascio/express-openapi-validator/commit/807e09c)), closes [#878](https://github.com/cdimascio/express-openapi-validator/issues/878) +- v5.1.1 ([4b0c989](https://github.com/cdimascio/express-openapi-validator/commit/4b0c989)) ## 5.1.1 (2023-11-21) -* Pass-through HttpError caught in multipart handler (#867) ([240c876](https://github.com/cdimascio/express-openapi-validator/commit/240c876)), closes [#867](https://github.com/cdimascio/express-openapi-validator/issues/867) -* v5.1.0 ([a9a3b0b](https://github.com/cdimascio/express-openapi-validator/commit/a9a3b0b)) -* v5.1.1 ([a4e62ac](https://github.com/cdimascio/express-openapi-validator/commit/a4e62ac)) - - +- Pass-through HttpError caught in multipart handler (#867) ([240c876](https://github.com/cdimascio/express-openapi-validator/commit/240c876)), closes [#867](https://github.com/cdimascio/express-openapi-validator/issues/867) +- v5.1.0 ([a9a3b0b](https://github.com/cdimascio/express-openapi-validator/commit/a9a3b0b)) +- v5.1.1 ([a4e62ac](https://github.com/cdimascio/express-openapi-validator/commit/a4e62ac)) ## 5.1.0 (2023-11-12) -* Allow optional use of `req.url` (#857) ([f732379](https://github.com/cdimascio/express-openapi-validator/commit/f732379)), closes [#857](https://github.com/cdimascio/express-openapi-validator/issues/857) -* Reorder upload and security middlewares (#866) ([95543d6](https://github.com/cdimascio/express-openapi-validator/commit/95543d6)), closes [#866](https://github.com/cdimascio/express-openapi-validator/issues/866) [#865](https://github.com/cdimascio/express-openapi-validator/issues/865) -* Update build and packaging scripts (#872) ([dd4027f](https://github.com/cdimascio/express-openapi-validator/commit/dd4027f)), closes [#872](https://github.com/cdimascio/express-openapi-validator/issues/872) -* update version locks ([bb8d6b8](https://github.com/cdimascio/express-openapi-validator/commit/bb8d6b8)) -* v5.1.0 ([839f859](https://github.com/cdimascio/express-openapi-validator/commit/839f859)) - - +- Allow optional use of `req.url` (#857) ([f732379](https://github.com/cdimascio/express-openapi-validator/commit/f732379)), closes [#857](https://github.com/cdimascio/express-openapi-validator/issues/857) +- Reorder upload and security middlewares (#866) ([95543d6](https://github.com/cdimascio/express-openapi-validator/commit/95543d6)), closes [#866](https://github.com/cdimascio/express-openapi-validator/issues/866) [#865](https://github.com/cdimascio/express-openapi-validator/issues/865) +- Update build and packaging scripts (#872) ([dd4027f](https://github.com/cdimascio/express-openapi-validator/commit/dd4027f)), closes [#872](https://github.com/cdimascio/express-openapi-validator/issues/872) +- update version locks ([bb8d6b8](https://github.com/cdimascio/express-openapi-validator/commit/bb8d6b8)) +- v5.1.0 ([839f859](https://github.com/cdimascio/express-openapi-validator/commit/839f859)) ## 5.0.5 (2023-08-23) -* #841 return error thrown in serDes deserializer (#842) ([d029401](https://github.com/cdimascio/express-openapi-validator/commit/d029401)), closes [#841](https://github.com/cdimascio/express-openapi-validator/issues/841) [#842](https://github.com/cdimascio/express-openapi-validator/issues/842) -* fix documentation links ([01950b7](https://github.com/cdimascio/express-openapi-validator/commit/01950b7)) -* fix example schema removal and upgrade patch version ([495dabd](https://github.com/cdimascio/express-openapi-validator/commit/495dabd)) -* fixing default export function issue (#846) ([268d38a](https://github.com/cdimascio/express-openapi-validator/commit/268d38a)), closes [#846](https://github.com/cdimascio/express-openapi-validator/issues/846) -* Remove body-parser deps in example (#845) ([c73b7c1](https://github.com/cdimascio/express-openapi-validator/commit/c73b7c1)), closes [#845](https://github.com/cdimascio/express-openapi-validator/issues/845) -* Remove examples from apiDoc when validating requests (#774) ([950d429](https://github.com/cdimascio/express-openapi-validator/commit/950d429)), closes [#774](https://github.com/cdimascio/express-openapi-validator/issues/774) -* Resolve "reference resolves to more than one schema" errors when AJV processes OpenAPI document and ([9d215be](https://github.com/cdimascio/express-openapi-validator/commit/9d215be)), closes [#853](https://github.com/cdimascio/express-openapi-validator/issues/853) -* v5.0.5 change history ([b5cc33a](https://github.com/cdimascio/express-openapi-validator/commit/b5cc33a)) - - +- #841 return error thrown in serDes deserializer (#842) ([d029401](https://github.com/cdimascio/express-openapi-validator/commit/d029401)), closes [#841](https://github.com/cdimascio/express-openapi-validator/issues/841) [#842](https://github.com/cdimascio/express-openapi-validator/issues/842) +- fix documentation links ([01950b7](https://github.com/cdimascio/express-openapi-validator/commit/01950b7)) +- fix example schema removal and upgrade patch version ([495dabd](https://github.com/cdimascio/express-openapi-validator/commit/495dabd)) +- fixing default export function issue (#846) ([268d38a](https://github.com/cdimascio/express-openapi-validator/commit/268d38a)), closes [#846](https://github.com/cdimascio/express-openapi-validator/issues/846) +- Remove body-parser deps in example (#845) ([c73b7c1](https://github.com/cdimascio/express-openapi-validator/commit/c73b7c1)), closes [#845](https://github.com/cdimascio/express-openapi-validator/issues/845) +- Remove examples from apiDoc when validating requests (#774) ([950d429](https://github.com/cdimascio/express-openapi-validator/commit/950d429)), closes [#774](https://github.com/cdimascio/express-openapi-validator/issues/774) +- Resolve "reference resolves to more than one schema" errors when AJV processes OpenAPI document and ([9d215be](https://github.com/cdimascio/express-openapi-validator/commit/9d215be)), closes [#853](https://github.com/cdimascio/express-openapi-validator/issues/853) +- v5.0.5 change history ([b5cc33a](https://github.com/cdimascio/express-openapi-validator/commit/b5cc33a)) ## 5.0.4 (2023-04-30) -* Switch json-schema-ref-parser to non-deprecated package (#829) ([f5bbce9](https://github.com/cdimascio/express-openapi-validator/commit/f5bbce9)), closes [#829](https://github.com/cdimascio/express-openapi-validator/issues/829) -* v5.0.4 ([9b89c79](https://github.com/cdimascio/express-openapi-validator/commit/9b89c79)) -* fix: Deserialize custom types with inline schemas (#823) ([d53621d](https://github.com/cdimascio/express-openapi-validator/commit/d53621d)), closes [#823](https://github.com/cdimascio/express-openapi-validator/issues/823) - - +- Switch json-schema-ref-parser to non-deprecated package (#829) ([f5bbce9](https://github.com/cdimascio/express-openapi-validator/commit/f5bbce9)), closes [#829](https://github.com/cdimascio/express-openapi-validator/issues/829) +- v5.0.4 ([9b89c79](https://github.com/cdimascio/express-openapi-validator/commit/9b89c79)) +- fix: Deserialize custom types with inline schemas (#823) ([d53621d](https://github.com/cdimascio/express-openapi-validator/commit/d53621d)), closes [#823](https://github.com/cdimascio/express-openapi-validator/issues/823) ## 5.0.3 (2023-03-04) -* FIx serialization/deserialization in additionalProperties (#822) ([a9067b8](https://github.com/cdimascio/express-openapi-validator/commit/a9067b8)), closes [#822](https://github.com/cdimascio/express-openapi-validator/issues/822) -* Rename field `error_code` to `errorCode` in `ValidationErrorItem` (#819) ([1a1b2cc](https://github.com/cdimascio/express-openapi-validator/commit/1a1b2cc)), closes [#819](https://github.com/cdimascio/express-openapi-validator/issues/819) -* v5.0.3 ([6e93a96](https://github.com/cdimascio/express-openapi-validator/commit/6e93a96)) -* chore(deps): bump cookiejar from 2.1.2 to 2.1.4 in /examples/9-nestjs (#805) ([07d9879](https://github.com/cdimascio/express-openapi-validator/commit/07d9879)), closes [#805](https://github.com/cdimascio/express-openapi-validator/issues/805) -* chore(deps): bump cookiejar from 2.1.3 to 2.1.4 (#806) ([0da34f8](https://github.com/cdimascio/express-openapi-validator/commit/0da34f8)), closes [#806](https://github.com/cdimascio/express-openapi-validator/issues/806) -* chore(deps): bump http-cache-semantics (#811) ([7a779f6](https://github.com/cdimascio/express-openapi-validator/commit/7a779f6)), closes [#811](https://github.com/cdimascio/express-openapi-validator/issues/811) -* chore(deps): bump http-cache-semantics (#813) ([336683d](https://github.com/cdimascio/express-openapi-validator/commit/336683d)), closes [#813](https://github.com/cdimascio/express-openapi-validator/issues/813) -* chore(deps): bump http-cache-semantics (#814) ([3721092](https://github.com/cdimascio/express-openapi-validator/commit/3721092)), closes [#814](https://github.com/cdimascio/express-openapi-validator/issues/814) -* chore(deps): bump http-cache-semantics (#816) ([466e337](https://github.com/cdimascio/express-openapi-validator/commit/466e337)), closes [#816](https://github.com/cdimascio/express-openapi-validator/issues/816) -* chore(deps): bump http-cache-semantics (#817) ([582b395](https://github.com/cdimascio/express-openapi-validator/commit/582b395)), closes [#817](https://github.com/cdimascio/express-openapi-validator/issues/817) -* chore(deps): bump http-cache-semantics in /examples/1-standard (#810) ([e6ef9d3](https://github.com/cdimascio/express-openapi-validator/commit/e6ef9d3)), closes [#810](https://github.com/cdimascio/express-openapi-validator/issues/810) -* chore(deps): bump http-cache-semantics in /examples/3-eov-operations (#812) ([fd04b5e](https://github.com/cdimascio/express-openapi-validator/commit/fd04b5e)), closes [#812](https://github.com/cdimascio/express-openapi-validator/issues/812) -* chore(deps): bump http-cache-semantics in /examples/6-multi-file-spec (#815) ([b2704b0](https://github.com/cdimascio/express-openapi-validator/commit/b2704b0)), closes [#815](https://github.com/cdimascio/express-openapi-validator/issues/815) -* chore(deps): bump json5 from 1.0.1 to 1.0.2 in /examples/9-nestjs (#801) ([30defdc](https://github.com/cdimascio/express-openapi-validator/commit/30defdc)), closes [#801](https://github.com/cdimascio/express-openapi-validator/issues/801) -* chore(deps): bump json5 in /examples/4-eov-operations-babel (#799) ([a100192](https://github.com/cdimascio/express-openapi-validator/commit/a100192)), closes [#799](https://github.com/cdimascio/express-openapi-validator/issues/799) -* fix: upgrade ajv from 8.11.0 to 8.11.2 (#797) ([e774d4b](https://github.com/cdimascio/express-openapi-validator/commit/e774d4b)), closes [#797](https://github.com/cdimascio/express-openapi-validator/issues/797) -* fix: upgrade body-parser from 1.19.0 to 1.20.1 (#798) ([87a2000](https://github.com/cdimascio/express-openapi-validator/commit/87a2000)), closes [#798](https://github.com/cdimascio/express-openapi-validator/issues/798) -* fix: upgrade content-type from 1.0.4 to 1.0.5 (#818) ([541d5f9](https://github.com/cdimascio/express-openapi-validator/commit/541d5f9)), closes [#818](https://github.com/cdimascio/express-openapi-validator/issues/818) - - +- FIx serialization/deserialization in additionalProperties (#822) ([a9067b8](https://github.com/cdimascio/express-openapi-validator/commit/a9067b8)), closes [#822](https://github.com/cdimascio/express-openapi-validator/issues/822) +- Rename field `error_code` to `errorCode` in `ValidationErrorItem` (#819) ([1a1b2cc](https://github.com/cdimascio/express-openapi-validator/commit/1a1b2cc)), closes [#819](https://github.com/cdimascio/express-openapi-validator/issues/819) +- v5.0.3 ([6e93a96](https://github.com/cdimascio/express-openapi-validator/commit/6e93a96)) +- chore(deps): bump cookiejar from 2.1.2 to 2.1.4 in /examples/9-nestjs (#805) ([07d9879](https://github.com/cdimascio/express-openapi-validator/commit/07d9879)), closes [#805](https://github.com/cdimascio/express-openapi-validator/issues/805) +- chore(deps): bump cookiejar from 2.1.3 to 2.1.4 (#806) ([0da34f8](https://github.com/cdimascio/express-openapi-validator/commit/0da34f8)), closes [#806](https://github.com/cdimascio/express-openapi-validator/issues/806) +- chore(deps): bump http-cache-semantics (#811) ([7a779f6](https://github.com/cdimascio/express-openapi-validator/commit/7a779f6)), closes [#811](https://github.com/cdimascio/express-openapi-validator/issues/811) +- chore(deps): bump http-cache-semantics (#813) ([336683d](https://github.com/cdimascio/express-openapi-validator/commit/336683d)), closes [#813](https://github.com/cdimascio/express-openapi-validator/issues/813) +- chore(deps): bump http-cache-semantics (#814) ([3721092](https://github.com/cdimascio/express-openapi-validator/commit/3721092)), closes [#814](https://github.com/cdimascio/express-openapi-validator/issues/814) +- chore(deps): bump http-cache-semantics (#816) ([466e337](https://github.com/cdimascio/express-openapi-validator/commit/466e337)), closes [#816](https://github.com/cdimascio/express-openapi-validator/issues/816) +- chore(deps): bump http-cache-semantics (#817) ([582b395](https://github.com/cdimascio/express-openapi-validator/commit/582b395)), closes [#817](https://github.com/cdimascio/express-openapi-validator/issues/817) +- chore(deps): bump http-cache-semantics in /examples/1-standard (#810) ([e6ef9d3](https://github.com/cdimascio/express-openapi-validator/commit/e6ef9d3)), closes [#810](https://github.com/cdimascio/express-openapi-validator/issues/810) +- chore(deps): bump http-cache-semantics in /examples/3-eov-operations (#812) ([fd04b5e](https://github.com/cdimascio/express-openapi-validator/commit/fd04b5e)), closes [#812](https://github.com/cdimascio/express-openapi-validator/issues/812) +- chore(deps): bump http-cache-semantics in /examples/6-multi-file-spec (#815) ([b2704b0](https://github.com/cdimascio/express-openapi-validator/commit/b2704b0)), closes [#815](https://github.com/cdimascio/express-openapi-validator/issues/815) +- chore(deps): bump json5 from 1.0.1 to 1.0.2 in /examples/9-nestjs (#801) ([30defdc](https://github.com/cdimascio/express-openapi-validator/commit/30defdc)), closes [#801](https://github.com/cdimascio/express-openapi-validator/issues/801) +- chore(deps): bump json5 in /examples/4-eov-operations-babel (#799) ([a100192](https://github.com/cdimascio/express-openapi-validator/commit/a100192)), closes [#799](https://github.com/cdimascio/express-openapi-validator/issues/799) +- fix: upgrade ajv from 8.11.0 to 8.11.2 (#797) ([e774d4b](https://github.com/cdimascio/express-openapi-validator/commit/e774d4b)), closes [#797](https://github.com/cdimascio/express-openapi-validator/issues/797) +- fix: upgrade body-parser from 1.19.0 to 1.20.1 (#798) ([87a2000](https://github.com/cdimascio/express-openapi-validator/commit/87a2000)), closes [#798](https://github.com/cdimascio/express-openapi-validator/issues/798) +- fix: upgrade content-type from 1.0.4 to 1.0.5 (#818) ([541d5f9](https://github.com/cdimascio/express-openapi-validator/commit/541d5f9)), closes [#818](https://github.com/cdimascio/express-openapi-validator/issues/818) ## 5.0.2 (2023-02-11) -* v5.0.2 ([3b0e70c](https://github.com/cdimascio/express-openapi-validator/commit/3b0e70c)) -* v5.0.2 ([24ad64f](https://github.com/cdimascio/express-openapi-validator/commit/24ad64f)) -* fix: objects in form-data (#730) ([e5cb5d6](https://github.com/cdimascio/express-openapi-validator/commit/e5cb5d6)), closes [#730](https://github.com/cdimascio/express-openapi-validator/issues/730) - - +- v5.0.2 ([3b0e70c](https://github.com/cdimascio/express-openapi-validator/commit/3b0e70c)) +- v5.0.2 ([24ad64f](https://github.com/cdimascio/express-openapi-validator/commit/24ad64f)) +- fix: objects in form-data (#730) ([e5cb5d6](https://github.com/cdimascio/express-openapi-validator/commit/e5cb5d6)), closes [#730](https://github.com/cdimascio/express-openapi-validator/issues/730) ## 5.0.1 (2023-01-09) -* enhance SchemaObject type (#697) ([ca43431](https://github.com/cdimascio/express-openapi-validator/commit/ca43431)), closes [#697](https://github.com/cdimascio/express-openapi-validator/issues/697) -* implement github actions workflow (#793) ([d415425](https://github.com/cdimascio/express-openapi-validator/commit/d415425)), closes [#793](https://github.com/cdimascio/express-openapi-validator/issues/793) -* Update README.md ([33da583](https://github.com/cdimascio/express-openapi-validator/commit/33da583)) -* Update README.md ([ccd981a](https://github.com/cdimascio/express-openapi-validator/commit/ccd981a)) -* v5.0.1 ([de0708b](https://github.com/cdimascio/express-openapi-validator/commit/de0708b)) -* chore(deps): bump ansi-regex from 3.0.0 to 3.0.1 in /examples/9-nestjs (#738) ([60afead](https://github.com/cdimascio/express-openapi-validator/commit/60afead)), closes [#738](https://github.com/cdimascio/express-openapi-validator/issues/738) -* chore(deps): bump minimatch from 3.0.4 to 3.1.2 in /examples/1-standard (#764) ([0d04305](https://github.com/cdimascio/express-openapi-validator/commit/0d04305)), closes [#764](https://github.com/cdimascio/express-openapi-validator/issues/764) -* chore(deps): bump minimatch from 3.0.4 to 3.1.2 in /examples/9-nestjs (#760) ([c1cf0d9](https://github.com/cdimascio/express-openapi-validator/commit/c1cf0d9)), closes [#760](https://github.com/cdimascio/express-openapi-validator/issues/760) -* chore(deps): bump minimatch in /examples/2-standard-multiple-api-specs (#763) ([fe5e95e](https://github.com/cdimascio/express-openapi-validator/commit/fe5e95e)), closes [#763](https://github.com/cdimascio/express-openapi-validator/issues/763) -* chore(deps): bump minimatch in /examples/3-eov-operations (#766) ([3285f3a](https://github.com/cdimascio/express-openapi-validator/commit/3285f3a)), closes [#766](https://github.com/cdimascio/express-openapi-validator/issues/766) -* chore(deps): bump minimatch in /examples/4-eov-operations-babel (#768) ([5bcc81b](https://github.com/cdimascio/express-openapi-validator/commit/5bcc81b)), closes [#768](https://github.com/cdimascio/express-openapi-validator/issues/768) -* chore(deps): bump minimatch in /examples/5-custom-operation-resolver (#765) ([b5b03b3](https://github.com/cdimascio/express-openapi-validator/commit/b5b03b3)), closes [#765](https://github.com/cdimascio/express-openapi-validator/issues/765) -* chore(deps): bump minimatch in /examples/6-multi-file-spec (#767) ([e8f54e8](https://github.com/cdimascio/express-openapi-validator/commit/e8f54e8)), closes [#767](https://github.com/cdimascio/express-openapi-validator/issues/767) -* chore(deps): bump minimatch in /examples/7-response-date-serialization (#759) ([9b9433e](https://github.com/cdimascio/express-openapi-validator/commit/9b9433e)), closes [#759](https://github.com/cdimascio/express-openapi-validator/issues/759) -* chore(deps): bump minimatch in /examples/8-top-level-discriminator (#761) ([46afe5c](https://github.com/cdimascio/express-openapi-validator/commit/46afe5c)), closes [#761](https://github.com/cdimascio/express-openapi-validator/issues/761) -* chore(deps): bump minimist and @nestjs/cli in /examples/9-nestjs (#769) ([8d31f9a](https://github.com/cdimascio/express-openapi-validator/commit/8d31f9a)), closes [#769](https://github.com/cdimascio/express-openapi-validator/issues/769) -* chore(deps): bump terser from 5.7.2 to 5.14.2 in /examples/9-nestjs (#750) ([a83ff9d](https://github.com/cdimascio/express-openapi-validator/commit/a83ff9d)), closes [#750](https://github.com/cdimascio/express-openapi-validator/issues/750) -* fix: upgrade body-parser from 1.19.0 to 1.19.1 (#689) ([40736f8](https://github.com/cdimascio/express-openapi-validator/commit/40736f8)), closes [#689](https://github.com/cdimascio/express-openapi-validator/issues/689) -* fix: upgrade body-parser from 1.19.0 to 1.19.1 (#690) ([9038edc](https://github.com/cdimascio/express-openapi-validator/commit/9038edc)), closes [#690](https://github.com/cdimascio/express-openapi-validator/issues/690) -* fix: upgrade body-parser from 1.19.0 to 1.19.1 (#691) ([e64a91c](https://github.com/cdimascio/express-openapi-validator/commit/e64a91c)), closes [#691](https://github.com/cdimascio/express-openapi-validator/issues/691) - - +- enhance SchemaObject type (#697) ([ca43431](https://github.com/cdimascio/express-openapi-validator/commit/ca43431)), closes [#697](https://github.com/cdimascio/express-openapi-validator/issues/697) +- implement github actions workflow (#793) ([d415425](https://github.com/cdimascio/express-openapi-validator/commit/d415425)), closes [#793](https://github.com/cdimascio/express-openapi-validator/issues/793) +- Update README.md ([33da583](https://github.com/cdimascio/express-openapi-validator/commit/33da583)) +- Update README.md ([ccd981a](https://github.com/cdimascio/express-openapi-validator/commit/ccd981a)) +- v5.0.1 ([de0708b](https://github.com/cdimascio/express-openapi-validator/commit/de0708b)) +- chore(deps): bump ansi-regex from 3.0.0 to 3.0.1 in /examples/9-nestjs (#738) ([60afead](https://github.com/cdimascio/express-openapi-validator/commit/60afead)), closes [#738](https://github.com/cdimascio/express-openapi-validator/issues/738) +- chore(deps): bump minimatch from 3.0.4 to 3.1.2 in /examples/1-standard (#764) ([0d04305](https://github.com/cdimascio/express-openapi-validator/commit/0d04305)), closes [#764](https://github.com/cdimascio/express-openapi-validator/issues/764) +- chore(deps): bump minimatch from 3.0.4 to 3.1.2 in /examples/9-nestjs (#760) ([c1cf0d9](https://github.com/cdimascio/express-openapi-validator/commit/c1cf0d9)), closes [#760](https://github.com/cdimascio/express-openapi-validator/issues/760) +- chore(deps): bump minimatch in /examples/2-standard-multiple-api-specs (#763) ([fe5e95e](https://github.com/cdimascio/express-openapi-validator/commit/fe5e95e)), closes [#763](https://github.com/cdimascio/express-openapi-validator/issues/763) +- chore(deps): bump minimatch in /examples/3-eov-operations (#766) ([3285f3a](https://github.com/cdimascio/express-openapi-validator/commit/3285f3a)), closes [#766](https://github.com/cdimascio/express-openapi-validator/issues/766) +- chore(deps): bump minimatch in /examples/4-eov-operations-babel (#768) ([5bcc81b](https://github.com/cdimascio/express-openapi-validator/commit/5bcc81b)), closes [#768](https://github.com/cdimascio/express-openapi-validator/issues/768) +- chore(deps): bump minimatch in /examples/5-custom-operation-resolver (#765) ([b5b03b3](https://github.com/cdimascio/express-openapi-validator/commit/b5b03b3)), closes [#765](https://github.com/cdimascio/express-openapi-validator/issues/765) +- chore(deps): bump minimatch in /examples/6-multi-file-spec (#767) ([e8f54e8](https://github.com/cdimascio/express-openapi-validator/commit/e8f54e8)), closes [#767](https://github.com/cdimascio/express-openapi-validator/issues/767) +- chore(deps): bump minimatch in /examples/7-response-date-serialization (#759) ([9b9433e](https://github.com/cdimascio/express-openapi-validator/commit/9b9433e)), closes [#759](https://github.com/cdimascio/express-openapi-validator/issues/759) +- chore(deps): bump minimatch in /examples/8-top-level-discriminator (#761) ([46afe5c](https://github.com/cdimascio/express-openapi-validator/commit/46afe5c)), closes [#761](https://github.com/cdimascio/express-openapi-validator/issues/761) +- chore(deps): bump minimist and @nestjs/cli in /examples/9-nestjs (#769) ([8d31f9a](https://github.com/cdimascio/express-openapi-validator/commit/8d31f9a)), closes [#769](https://github.com/cdimascio/express-openapi-validator/issues/769) +- chore(deps): bump terser from 5.7.2 to 5.14.2 in /examples/9-nestjs (#750) ([a83ff9d](https://github.com/cdimascio/express-openapi-validator/commit/a83ff9d)), closes [#750](https://github.com/cdimascio/express-openapi-validator/issues/750) +- fix: upgrade body-parser from 1.19.0 to 1.19.1 (#689) ([40736f8](https://github.com/cdimascio/express-openapi-validator/commit/40736f8)), closes [#689](https://github.com/cdimascio/express-openapi-validator/issues/689) +- fix: upgrade body-parser from 1.19.0 to 1.19.1 (#690) ([9038edc](https://github.com/cdimascio/express-openapi-validator/commit/9038edc)), closes [#690](https://github.com/cdimascio/express-openapi-validator/issues/690) +- fix: upgrade body-parser from 1.19.0 to 1.19.1 (#691) ([e64a91c](https://github.com/cdimascio/express-openapi-validator/commit/e64a91c)), closes [#691](https://github.com/cdimascio/express-openapi-validator/issues/691) ## 5.0.0 (2022-11-19) -* Fix #699 serdes missed on items in a collection, with tests. (#704) ([77bc4ae](https://github.com/cdimascio/express-openapi-validator/commit/77bc4ae)), closes [#699](https://github.com/cdimascio/express-openapi-validator/issues/699) [#704](https://github.com/cdimascio/express-openapi-validator/issues/704) -* fixed router parameters (#762) ([2bbed6f](https://github.com/cdimascio/express-openapi-validator/commit/2bbed6f)), closes [#762](https://github.com/cdimascio/express-openapi-validator/issues/762) -* v5.0.0 with ajv8 ([1d1d71b](https://github.com/cdimascio/express-openapi-validator/commit/1d1d71b)) - - +- Fix #699 serdes missed on items in a collection, with tests. (#704) ([77bc4ae](https://github.com/cdimascio/express-openapi-validator/commit/77bc4ae)), closes [#699](https://github.com/cdimascio/express-openapi-validator/issues/699) [#704](https://github.com/cdimascio/express-openapi-validator/issues/704) +- fixed router parameters (#762) ([2bbed6f](https://github.com/cdimascio/express-openapi-validator/commit/2bbed6f)), closes [#762](https://github.com/cdimascio/express-openapi-validator/issues/762) +- v5.0.0 with ajv8 ([1d1d71b](https://github.com/cdimascio/express-openapi-validator/commit/1d1d71b)) ## 4.13.8 (2022-05-30) -* Bump AJV to v8 (#713) ([2b27332](https://github.com/cdimascio/express-openapi-validator/commit/2b27332)), closes [#713](https://github.com/cdimascio/express-openapi-validator/issues/713) -* Bump multer to version that removes dicer as sub-dependency (#739) ([6501a62](https://github.com/cdimascio/express-openapi-validator/commit/6501a62)), closes [#739](https://github.com/cdimascio/express-openapi-validator/issues/739) -* update ansi-regex ([6448f45](https://github.com/cdimascio/express-openapi-validator/commit/6448f45)) -* Update README.md ([c954b4b](https://github.com/cdimascio/express-openapi-validator/commit/c954b4b)) -* v4.14.0-beta.1 ([369a4a6](https://github.com/cdimascio/express-openapi-validator/commit/369a4a6)) -* v4.14.0-beta.2 ([1706538](https://github.com/cdimascio/express-openapi-validator/commit/1706538)) -* chore(deps): bump ansi-regex in /examples/2-standard-multiple-api-specs (#727) ([3e803b5](https://github.com/cdimascio/express-openapi-validator/commit/3e803b5)), closes [#727](https://github.com/cdimascio/express-openapi-validator/issues/727) -* chore(deps): bump ansi-regex in /examples/3-eov-operations (#726) ([aba3cd0](https://github.com/cdimascio/express-openapi-validator/commit/aba3cd0)), closes [#726](https://github.com/cdimascio/express-openapi-validator/issues/726) -* chore(deps): bump ansi-regex in /examples/5-custom-operation-resolver (#725) ([2bf250e](https://github.com/cdimascio/express-openapi-validator/commit/2bf250e)), closes [#725](https://github.com/cdimascio/express-openapi-validator/issues/725) -* chore(deps): bump ansi-regex in /examples/6-multi-file-spec (#723) ([e29c1eb](https://github.com/cdimascio/express-openapi-validator/commit/e29c1eb)), closes [#723](https://github.com/cdimascio/express-openapi-validator/issues/723) -* chore(deps): bump ansi-regex in /examples/7-response-date-serialization (#722) ([acdae50](https://github.com/cdimascio/express-openapi-validator/commit/acdae50)), closes [#722](https://github.com/cdimascio/express-openapi-validator/issues/722) -* chore(deps): bump ansi-regex in /examples/8-top-level-discriminator (#719) ([45059a6](https://github.com/cdimascio/express-openapi-validator/commit/45059a6)), closes [#719](https://github.com/cdimascio/express-openapi-validator/issues/719) -* chore(deps): bump follow-redirects in /examples/9-nestjs (#705) ([15e91aa](https://github.com/cdimascio/express-openapi-validator/commit/15e91aa)), closes [#705](https://github.com/cdimascio/express-openapi-validator/issues/705) -* chore(deps): bump minimist from 1.2.5 to 1.2.6 in /examples/1-standard (#714) ([1eecf40](https://github.com/cdimascio/express-openapi-validator/commit/1eecf40)), closes [#714](https://github.com/cdimascio/express-openapi-validator/issues/714) -* chore(deps): bump minimist in /examples/2-standard-multiple-api-specs (#716) ([6f6ea71](https://github.com/cdimascio/express-openapi-validator/commit/6f6ea71)), closes [#716](https://github.com/cdimascio/express-openapi-validator/issues/716) -* chore(deps): bump minimist in /examples/3-eov-operations (#715) ([3f6cb37](https://github.com/cdimascio/express-openapi-validator/commit/3f6cb37)), closes [#715](https://github.com/cdimascio/express-openapi-validator/issues/715) -* chore(deps): bump minimist in /examples/4-eov-operations-babel (#717) ([6b90f35](https://github.com/cdimascio/express-openapi-validator/commit/6b90f35)), closes [#717](https://github.com/cdimascio/express-openapi-validator/issues/717) -* chore(deps): bump minimist in /examples/5-custom-operation-resolver (#718) ([acc3f33](https://github.com/cdimascio/express-openapi-validator/commit/acc3f33)), closes [#718](https://github.com/cdimascio/express-openapi-validator/issues/718) -* chore(deps): bump minimist in /examples/6-multi-file-spec (#724) ([15814ba](https://github.com/cdimascio/express-openapi-validator/commit/15814ba)), closes [#724](https://github.com/cdimascio/express-openapi-validator/issues/724) -* chore(deps): bump minimist in /examples/7-response-date-serialization (#721) ([ff63618](https://github.com/cdimascio/express-openapi-validator/commit/ff63618)), closes [#721](https://github.com/cdimascio/express-openapi-validator/issues/721) -* chore(deps): bump minimist in /examples/8-top-level-discriminator (#720) ([a23a09f](https://github.com/cdimascio/express-openapi-validator/commit/a23a09f)), closes [#720](https://github.com/cdimascio/express-openapi-validator/issues/720) -* chore(deps): bump node-fetch from 2.6.1 to 2.6.7 in /examples/9-nestjs (#711) ([87bb6df](https://github.com/cdimascio/express-openapi-validator/commit/87bb6df)), closes [#711](https://github.com/cdimascio/express-openapi-validator/issues/711) - - +- Bump AJV to v8 (#713) ([2b27332](https://github.com/cdimascio/express-openapi-validator/commit/2b27332)), closes [#713](https://github.com/cdimascio/express-openapi-validator/issues/713) +- Bump multer to version that removes dicer as sub-dependency (#739) ([6501a62](https://github.com/cdimascio/express-openapi-validator/commit/6501a62)), closes [#739](https://github.com/cdimascio/express-openapi-validator/issues/739) +- update ansi-regex ([6448f45](https://github.com/cdimascio/express-openapi-validator/commit/6448f45)) +- Update README.md ([c954b4b](https://github.com/cdimascio/express-openapi-validator/commit/c954b4b)) +- v4.14.0-beta.1 ([369a4a6](https://github.com/cdimascio/express-openapi-validator/commit/369a4a6)) +- v4.14.0-beta.2 ([1706538](https://github.com/cdimascio/express-openapi-validator/commit/1706538)) +- chore(deps): bump ansi-regex in /examples/2-standard-multiple-api-specs (#727) ([3e803b5](https://github.com/cdimascio/express-openapi-validator/commit/3e803b5)), closes [#727](https://github.com/cdimascio/express-openapi-validator/issues/727) +- chore(deps): bump ansi-regex in /examples/3-eov-operations (#726) ([aba3cd0](https://github.com/cdimascio/express-openapi-validator/commit/aba3cd0)), closes [#726](https://github.com/cdimascio/express-openapi-validator/issues/726) +- chore(deps): bump ansi-regex in /examples/5-custom-operation-resolver (#725) ([2bf250e](https://github.com/cdimascio/express-openapi-validator/commit/2bf250e)), closes [#725](https://github.com/cdimascio/express-openapi-validator/issues/725) +- chore(deps): bump ansi-regex in /examples/6-multi-file-spec (#723) ([e29c1eb](https://github.com/cdimascio/express-openapi-validator/commit/e29c1eb)), closes [#723](https://github.com/cdimascio/express-openapi-validator/issues/723) +- chore(deps): bump ansi-regex in /examples/7-response-date-serialization (#722) ([acdae50](https://github.com/cdimascio/express-openapi-validator/commit/acdae50)), closes [#722](https://github.com/cdimascio/express-openapi-validator/issues/722) +- chore(deps): bump ansi-regex in /examples/8-top-level-discriminator (#719) ([45059a6](https://github.com/cdimascio/express-openapi-validator/commit/45059a6)), closes [#719](https://github.com/cdimascio/express-openapi-validator/issues/719) +- chore(deps): bump follow-redirects in /examples/9-nestjs (#705) ([15e91aa](https://github.com/cdimascio/express-openapi-validator/commit/15e91aa)), closes [#705](https://github.com/cdimascio/express-openapi-validator/issues/705) +- chore(deps): bump minimist from 1.2.5 to 1.2.6 in /examples/1-standard (#714) ([1eecf40](https://github.com/cdimascio/express-openapi-validator/commit/1eecf40)), closes [#714](https://github.com/cdimascio/express-openapi-validator/issues/714) +- chore(deps): bump minimist in /examples/2-standard-multiple-api-specs (#716) ([6f6ea71](https://github.com/cdimascio/express-openapi-validator/commit/6f6ea71)), closes [#716](https://github.com/cdimascio/express-openapi-validator/issues/716) +- chore(deps): bump minimist in /examples/3-eov-operations (#715) ([3f6cb37](https://github.com/cdimascio/express-openapi-validator/commit/3f6cb37)), closes [#715](https://github.com/cdimascio/express-openapi-validator/issues/715) +- chore(deps): bump minimist in /examples/4-eov-operations-babel (#717) ([6b90f35](https://github.com/cdimascio/express-openapi-validator/commit/6b90f35)), closes [#717](https://github.com/cdimascio/express-openapi-validator/issues/717) +- chore(deps): bump minimist in /examples/5-custom-operation-resolver (#718) ([acc3f33](https://github.com/cdimascio/express-openapi-validator/commit/acc3f33)), closes [#718](https://github.com/cdimascio/express-openapi-validator/issues/718) +- chore(deps): bump minimist in /examples/6-multi-file-spec (#724) ([15814ba](https://github.com/cdimascio/express-openapi-validator/commit/15814ba)), closes [#724](https://github.com/cdimascio/express-openapi-validator/issues/724) +- chore(deps): bump minimist in /examples/7-response-date-serialization (#721) ([ff63618](https://github.com/cdimascio/express-openapi-validator/commit/ff63618)), closes [#721](https://github.com/cdimascio/express-openapi-validator/issues/721) +- chore(deps): bump minimist in /examples/8-top-level-discriminator (#720) ([a23a09f](https://github.com/cdimascio/express-openapi-validator/commit/a23a09f)), closes [#720](https://github.com/cdimascio/express-openapi-validator/issues/720) +- chore(deps): bump node-fetch from 2.6.1 to 2.6.7 in /examples/9-nestjs (#711) ([87bb6df](https://github.com/cdimascio/express-openapi-validator/commit/87bb6df)), closes [#711](https://github.com/cdimascio/express-openapi-validator/issues/711) ## 4.13.7 (2022-03-27) -* migrate README to wiki ([4887ba5](https://github.com/cdimascio/express-openapi-validator/commit/4887ba5)) -* Update README ([13b26d6](https://github.com/cdimascio/express-openapi-validator/commit/13b26d6)) - - - +- migrate README to wiki ([4887ba5](https://github.com/cdimascio/express-openapi-validator/commit/4887ba5)) +- Update README ([13b26d6](https://github.com/cdimascio/express-openapi-validator/commit/13b26d6)) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 5d506909..ee9d2140 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or + advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic + address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting ## Our Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd88b86d..1a8368fc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,6 +5,7 @@ Contributors are welcome! See something that needs fixing? Got an idea for a new feature? Contribute a [Pull Request](#Create-a-Pull-Request)! ## Easy path to contribution + Click the Gitpod badge to setup a ready to code dev env in the cloud. [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdimascio/express-openapi-validator) @@ -26,7 +27,7 @@ Click the Gitpod badge to setup a ready to code dev env in the cloud. # From the project directory, run npm i ``` - + Be [Create a Pull Request](#create-a-pull-request) once you've written you code. ## Run the tests @@ -56,11 +57,12 @@ Be [Create a Pull Request](#create-a-pull-request) once you've written you code. 3. Make a new branch 4. Make your changes 5. Push it back to your repo -6. From the Github UI, Click the Compare & pull request button +6. From the Github UI, Click the Compare & pull request button NOTE: this button will be present for some period of time after 5. If the button no longer there, Create pull request and select the branches manually) -6. From the Github UI, Click Create pull request to open a new pull request -7. Detailed steps with example here: + +7. From the Github UI, Click Create pull request to open a new pull request +8. Detailed steps with example here: ## Project structure @@ -74,12 +76,13 @@ Reach out on [gitter](https://gitter.im/cdimascio-oss/community). We're happy to help! ## FAQ + **Q:** I don't have permission to create a branch and I can't push my changes **A:** You cannot directly create a branch in this repo. Instead [Create a Pull Request](#create-a-pull-request) +## Misc -## Misc If you are not a project, you may ignore this section ### Generate Change Log diff --git a/README.md b/README.md index 0ad1a377..cd79eebf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # 🦋 express-openapi-validator -[![example workflow](https://github.com/cdimascio/express-openapi-validator/actions/workflows/default.yml/badge.svg)](#) [![](https://img.shields.io/npm/v/express-openapi-validator.svg)](https://www.npmjs.com/package/express-openapi-validator) [![](https://img.shields.io/npm/dm/express-openapi-validator?color=blue)](https://www.npmjs.com/package/express-openapi-validator) [![All Contributors](https://img.shields.io/github/contributors/cdimascio/express-openapi-validator -)](#contributors) [![Coverage Status](https://coveralls.io/repos/github/cdimascio/express-openapi-validator/badge.svg?branch=master)](https://coveralls.io/github/cdimascio/express-openapi-validator?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/1570a06f609345ddb237114bbd6ceed7)](https://www.codacy.com/manual/cdimascio/express-openapi-validator?utm_source=github.com&utm_medium=referral&utm_content=cdimascio/express-openapi-validator&utm_campaign=Badge_Grade) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdimascio/express-openapi-validator) [![](https://img.shields.io/badge/documentation-yes-informational)](https://cdimascio.github.io/express-openapi-validator-documentation/) [![](https://img.shields.io/badge/license-MIT-blue.svg)](#license) +[![example workflow](https://github.com/cdimascio/express-openapi-validator/actions/workflows/default.yml/badge.svg)](#) [![](https://img.shields.io/npm/v/express-openapi-validator.svg)](https://www.npmjs.com/package/express-openapi-validator) [![](https://img.shields.io/npm/dm/express-openapi-validator?color=blue)](https://www.npmjs.com/package/express-openapi-validator) [![All Contributors](https://img.shields.io/github/contributors/cdimascio/express-openapi-validator)](#contributors) [![Coverage Status](https://coveralls.io/repos/github/cdimascio/express-openapi-validator/badge.svg?branch=master)](https://coveralls.io/github/cdimascio/express-openapi-validator?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/1570a06f609345ddb237114bbd6ceed7)](https://www.codacy.com/manual/cdimascio/express-openapi-validator?utm_source=github.com&utm_medium=referral&utm_content=cdimascio/express-openapi-validator&utm_campaign=Badge_Grade) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdimascio/express-openapi-validator) [![](https://img.shields.io/badge/documentation-yes-informational)](https://cdimascio.github.io/express-openapi-validator-documentation/) [![](https://img.shields.io/badge/license-MIT-blue.svg)](#license) **An OpenApi validator for ExpressJS** that automatically validates **API** _**requests**_ and _**responses**_ using an **OpenAPI 3** specification. @@ -22,6 +21,7 @@ - 🎈 file upload **Docs:** + - 📖 [documentation](https://cdimascio.github.io/express-openapi-validator-documentation/) [![GitHub stars](https://img.shields.io/github/stars/cdimascio/express-openapi-validator.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/cdimascio/express-openapi-validator/stargazers/) [![Twitter URL](https://img.shields.io/twitter/url/https/github.com/cdimascio/express-openapi-validator.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20express-openapi-validator%20by%20%40CarmineDiMascio%20https%3A%2F%2Fgithub.com%2Fcdimascio%2Fexpress-openapi-validator%20%F0%9F%91%8D) @@ -81,7 +81,7 @@ _**Important:** Ensure express is configured with all relevant body parsers. Bod See the [doc](https://cdimascio.github.io/express-openapi-validator-documentation/) for complete documenation -_deprecated_ [legacy doc](https://github.com/cdimascio/express-openapi-validator/wiki) +_deprecated_ [legacy doc](https://github.com/cdimascio/express-openapi-validator/wiki) ## License diff --git a/SECURITY.md b/SECURITY.md index 66ba1532..580ae68c 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -9,7 +9,6 @@ currently being supported with security updates. | ------- | ------------------ | | 5.3.x | :white_check_mark: | - ## Reporting a Vulnerability Use this section to tell people how to report a vulnerability. diff --git a/_config.yml b/_config.yml index c4192631..277f1f2c 100644 --- a/_config.yml +++ b/_config.yml @@ -1 +1 @@ -theme: jekyll-theme-cayman \ No newline at end of file +theme: jekyll-theme-cayman diff --git a/examples/1-standard-oas-3.1/README.md b/examples/1-standard-oas-3.1/README.md index 27e6e48b..ecfa6100 100644 --- a/examples/1-standard-oas-3.1/README.md +++ b/examples/1-standard-oas-3.1/README.md @@ -32,6 +32,7 @@ curl http://localhost:3000/v1/pets ### GET /pets success + ```shell curl -s 'localhost:3000/v1/pets?limit=5' |jq [ @@ -60,7 +61,8 @@ curl -s 'localhost:3000/v1/pets?limit=5' |jq ] ``` -error +error + ```shell curl -s 'localhost:3000/v1/pets' |jq { @@ -79,6 +81,7 @@ error ### POST /pets success + ```shell curl -s -XPOST 'localhost:3000/v1/pets' -d '{"id": 1, "name": "jobe"}' -H 'Content-type: application/json'|jq { @@ -88,6 +91,7 @@ curl -s -XPOST 'localhost:3000/v1/pets' -d '{"id": 1, "name": "jobe"}' -H 'Conte ``` error + ```shell curl -s -XPOST 'localhost:3000/v1/pets' -d '{"id": "sdfsf", "name": "jobe"}' -H 'Content-type: application/json'|jq { @@ -106,6 +110,7 @@ curl -s -XPOST 'localhost:3000/v1/pets' -d '{"id": "sdfsf", "name": "jobe"}' -H ### GET /pets/:id success + ```shell curl -s 'localhost:3000/v1/pets/1' |jq { @@ -119,6 +124,7 @@ curl -s 'localhost:3000/v1/pets/1' |jq ``` error: bad id type + ```shell curl -s 'localhost:3000/v1/pets/lkl' |jq { @@ -134,10 +140,10 @@ curl -s 'localhost:3000/v1/pets/lkl' |jq } ``` - ### /v1/pets/1/photos success + ```shell curl -XPOST 'localhost:3000/v1/pets/1/photos' -H 'Content-type: multipart/form-data' -F 'file=@test.txt'|jq % Total % Received % Xferd Average Speed Time Time Time Current @@ -155,6 +161,7 @@ curl -XPOST 'localhost:3000/v1/pets/1/photos' -H 'Content-type: multipart/form- ``` error: no file + ```shell curl -s -XPOST 'localhost:3000/v1/pets/1/photos' -H 'Content-type: multipart/form-data' |jq { @@ -169,4 +176,3 @@ error: no file "code": 400 } ``` - diff --git a/examples/1-standard-oas-3.1/app.js b/examples/1-standard-oas-3.1/app.js index 8ee5d613..f600196a 100644 --- a/examples/1-standard-oas-3.1/app.js +++ b/examples/1-standard-oas-3.1/app.js @@ -79,7 +79,6 @@ app.use((err, req, res, next) => { }); }); - http.createServer(app).listen(port); console.log(`Listening on port ${port}`); diff --git a/examples/1-standard-oas-3.1/services/index.js b/examples/1-standard-oas-3.1/services/index.js index 952dc10a..5e61d4b1 100644 --- a/examples/1-standard-oas-3.1/services/index.js +++ b/examples/1-standard-oas-3.1/services/index.js @@ -24,12 +24,17 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter(d => !type || d.type === type).slice(0, limit); + return data.filter((d) => !type || d.type === type).slice(0, limit); } findById(id) { - console.log(id, data, data.filter(p => p.id === id), typeof id); - return data.filter(p => p.id === id)[0]; + console.log( + id, + data, + data.filter((p) => p.id === id), + typeof id, + ); + return data.filter((p) => p.id === id)[0]; } create(pet) { @@ -39,6 +44,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter(e => e.id !== id); + return data.filter((e) => e.id !== id); } }; diff --git a/examples/1-standard/services/index.js b/examples/1-standard/services/index.js index 47cef69a..d7822814 100644 --- a/examples/1-standard/services/index.js +++ b/examples/1-standard/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter(d => d.type === type).slice(0, limit); + return data.filter((d) => d.type === type).slice(0, limit); } findById(id) { - return data.filter(p => p.id === id)[0]; + return data.filter((p) => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter(e => e.id !== id); + return data.filter((e) => e.id !== id); } }; diff --git a/examples/3-eov-operations/routes/pets.js b/examples/3-eov-operations/routes/pets.js index 0f8c89a3..354f5f9a 100644 --- a/examples/3-eov-operations/routes/pets.js +++ b/examples/3-eov-operations/routes/pets.js @@ -23,7 +23,7 @@ module.exports = { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map(f => ({ + files_metadata: req.files.map((f) => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, diff --git a/examples/3-eov-operations/services/index.js b/examples/3-eov-operations/services/index.js index 1c7afd6e..d7822814 100644 --- a/examples/3-eov-operations/services/index.js +++ b/examples/3-eov-operations/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter(d => d.type === type).slice(0, limit); + return data.filter((d) => d.type === type).slice(0, limit); } findById(id) { - return data.filter(p => p.id === id)[0]; + return data.filter((p) => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter(e => e.id !== id); + return data.filter((e) => e.id !== id); } -} +}; diff --git a/examples/4-eov-operations-babel/.babelrc b/examples/4-eov-operations-babel/.babelrc index 022790fc..394c5435 100644 --- a/examples/4-eov-operations-babel/.babelrc +++ b/examples/4-eov-operations-babel/.babelrc @@ -1,12 +1,12 @@ { - "presets": [ - [ - "@babel/preset-env", - { - "targets": { - "node": "current" - } + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "node": "current" } - ] + } ] - } \ No newline at end of file + ] +} diff --git a/examples/4-eov-operations-babel/src/api.yaml b/examples/4-eov-operations-babel/src/api.yaml index 5f8906e4..9c641f3d 100644 --- a/examples/4-eov-operations-babel/src/api.yaml +++ b/examples/4-eov-operations-babel/src/api.yaml @@ -15,8 +15,8 @@ paths: description: | ping then pong! # use operationId, (x-eov-operation-id is optional. it can be used in place of operationId or to override it) - operationId: ping - x-eov-operation-handler: routes/ping + operationId: ping + x-eov-operation-handler: routes/ping responses: '200': description: OK diff --git a/examples/4-eov-operations-babel/src/routes/pets.js b/examples/4-eov-operations-babel/src/routes/pets.js index 5827b1ac..053ee158 100644 --- a/examples/4-eov-operations-babel/src/routes/pets.js +++ b/examples/4-eov-operations-babel/src/routes/pets.js @@ -23,7 +23,7 @@ export default { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map(f => ({ + files_metadata: req.files.map((f) => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, diff --git a/examples/4-eov-operations-babel/src/services/index.js b/examples/4-eov-operations-babel/src/services/index.js index 1c7afd6e..d7822814 100644 --- a/examples/4-eov-operations-babel/src/services/index.js +++ b/examples/4-eov-operations-babel/src/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter(d => d.type === type).slice(0, limit); + return data.filter((d) => d.type === type).slice(0, limit); } findById(id) { - return data.filter(p => p.id === id)[0]; + return data.filter((p) => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter(e => e.id !== id); + return data.filter((e) => e.id !== id); } -} +}; diff --git a/examples/5-custom-operation-resolver/README.md b/examples/5-custom-operation-resolver/README.md index f55663ab..ade73ffc 100644 --- a/examples/5-custom-operation-resolver/README.md +++ b/examples/5-custom-operation-resolver/README.md @@ -29,7 +29,7 @@ curl http://localhost:3000/v1/pets ## [Example Express API Server: with custom operation resolver](https://github.com/cdimascio/express-openapi-validator/tree/master/examples/5-custom-operation-resolver) -By default, when you configure `operationHandlers` to be the base path to your operation handler files, we use `operationId`, `x-eov-operation-id` and `x-eov-operation-handler` to determine what request handler should be used during routing. +By default, when you configure `operationHandlers` to be the base path to your operation handler files, we use `operationId`, `x-eov-operation-id` and `x-eov-operation-handler` to determine what request handler should be used during routing. If you ever want _FULL_ control over how that resolution happens (e.g. you want to use your own extended attributes or simply rely on `operationId`), then here's how you can accomplish that following an example where our `operationId` becomes a template that follows `{module}.{function}`. @@ -58,16 +58,20 @@ new OpenApiValidator({ } }); ``` + - Next, use `operationId` to specify the id of opeartion handler to invoke. + ```yaml /pets: get: - # This means our resolver will look for a file named "pets.js" at our - # configured base path and will return an export named "list" from + # This means our resolver will look for a file named "pets.js" at our + # configured base path and will return an export named "list" from # that module as the Express RequestHandler. operationId: pets.list ``` + - Finally, create the express handler module e.g. `routes/pets.js` + ```javascript module.exports = { // the express handler implementation for the pets collection diff --git a/examples/5-custom-operation-resolver/api.yaml b/examples/5-custom-operation-resolver/api.yaml index 8b3dd535..c9e1e721 100644 --- a/examples/5-custom-operation-resolver/api.yaml +++ b/examples/5-custom-operation-resolver/api.yaml @@ -14,7 +14,7 @@ paths: get: description: | ping then pong! - operationId: ping.ping + operationId: ping.ping responses: '200': description: OK diff --git a/examples/5-custom-operation-resolver/routes/pets.js b/examples/5-custom-operation-resolver/routes/pets.js index dd51ead9..cd0e800b 100644 --- a/examples/5-custom-operation-resolver/routes/pets.js +++ b/examples/5-custom-operation-resolver/routes/pets.js @@ -23,7 +23,7 @@ module.exports = { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map(f => ({ + files_metadata: req.files.map((f) => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, diff --git a/examples/5-custom-operation-resolver/services/index.js b/examples/5-custom-operation-resolver/services/index.js index 1c7afd6e..d7822814 100644 --- a/examples/5-custom-operation-resolver/services/index.js +++ b/examples/5-custom-operation-resolver/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter(d => d.type === type).slice(0, limit); + return data.filter((d) => d.type === type).slice(0, limit); } findById(id) { - return data.filter(p => p.id === id)[0]; + return data.filter((p) => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter(e => e.id !== id); + return data.filter((e) => e.id !== id); } -} +}; diff --git a/examples/6-multi-file-spec/README.md b/examples/6-multi-file-spec/README.md index db102d3f..d422a72a 100644 --- a/examples/6-multi-file-spec/README.md +++ b/examples/6-multi-file-spec/README.md @@ -19,6 +19,7 @@ npm start ## Try correct validation response with a multi-file spec + ``` curl -s -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{}'|jq { @@ -36,6 +37,6 @@ curl -s -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d add the required id and it returns correct ``` -curl -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{"id": 123}' -{} # note this test server returns empty object upon valid request -``` \ No newline at end of file +curl -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{"id": 123}' +{} # note this test server returns empty object upon valid request +``` diff --git a/examples/6-multi-file-spec/ems.yaml b/examples/6-multi-file-spec/ems.yaml index 2a11f7a2..bcdc83f2 100644 --- a/examples/6-multi-file-spec/ems.yaml +++ b/examples/6-multi-file-spec/ems.yaml @@ -93,4 +93,4 @@ components: content: application/json: schema: - $ref: 'schemas/queryrequest.yaml' \ No newline at end of file + $ref: 'schemas/queryrequest.yaml' diff --git a/examples/6-multi-file-spec/schemas/queries.yaml b/examples/6-multi-file-spec/schemas/queries.yaml index 4ed219d8..9b107d61 100644 --- a/examples/6-multi-file-spec/schemas/queries.yaml +++ b/examples/6-multi-file-spec/schemas/queries.yaml @@ -1,3 +1,3 @@ type: array items: - $ref: 'queryrequest.yaml' \ No newline at end of file + $ref: 'queryrequest.yaml' diff --git a/examples/6-multi-file-spec/schemas/queryrequest.yaml b/examples/6-multi-file-spec/schemas/queryrequest.yaml index ebbab9d0..b792a96c 100644 --- a/examples/6-multi-file-spec/schemas/queryrequest.yaml +++ b/examples/6-multi-file-spec/schemas/queryrequest.yaml @@ -10,4 +10,4 @@ properties: type: string folder: type: string - nullable: true \ No newline at end of file + nullable: true diff --git a/examples/6-multi-file-spec/schemas/queryrequests.yaml b/examples/6-multi-file-spec/schemas/queryrequests.yaml index 8d97ec5c..58c1bfaa 100644 --- a/examples/6-multi-file-spec/schemas/queryrequests.yaml +++ b/examples/6-multi-file-spec/schemas/queryrequests.yaml @@ -3,4 +3,4 @@ properties: list: type: array items: - type: string \ No newline at end of file + type: string diff --git a/examples/7-response-date-serialization/api.yaml b/examples/7-response-date-serialization/api.yaml index 1f3cbd98..840d3b8c 100644 --- a/examples/7-response-date-serialization/api.yaml +++ b/examples/7-response-date-serialization/api.yaml @@ -34,7 +34,7 @@ paths: application/json: schema: $ref: '#/components/schemas/User' - + components: schemas: Date: @@ -43,8 +43,7 @@ components: User: type: object properties: - id: + id: type: number created_at: - $ref: "#/components/schemas/Date" - \ No newline at end of file + $ref: '#/components/schemas/Date' diff --git a/launch.json b/launch.json index ec4d7e8a..86b7ca51 100644 --- a/launch.json +++ b/launch.json @@ -4,7 +4,6 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ - { "name": "Attach", "port": 9229, diff --git a/src/framework/ajv/factory.ts b/src/framework/ajv/factory.ts index 9571bc5a..30b3d29c 100644 --- a/src/framework/ajv/factory.ts +++ b/src/framework/ajv/factory.ts @@ -1,19 +1,19 @@ -import { Options } from "ajv"; +import { Options } from 'ajv'; import AjvDraft4 from 'ajv-draft-04'; import Ajv2020 from 'ajv/dist/2020'; -import { assertVersion } from "../openapi/assert.version"; -import { AjvInstance } from "../types"; +import { assertVersion } from '../openapi/assert.version'; +import { AjvInstance } from '../types'; export const factoryAjv = (version: string, options: Options): AjvInstance => { - const { minor } = assertVersion(version) + const { minor } = assertVersion(version); - let ajvInstance: AjvInstance + let ajvInstance: AjvInstance; if (minor === '0') { ajvInstance = new AjvDraft4(options); } else if (minor == '1') { ajvInstance = new Ajv2020(options); - + // Open API 3.1 has a custom "media-range" attribute defined in its schema, but the spec does not define it. "It's not really intended to be validated" // https://github.com/OAI/OpenAPI-Specification/issues/2714#issuecomment-923185689 // Since the schema is non-normative (https://github.com/OAI/OpenAPI-Specification/pull/3355#issuecomment-1915695294) we will only validate that it's a string @@ -21,5 +21,5 @@ export const factoryAjv = (version: string, options: Options): AjvInstance => { ajvInstance.addFormat('media-range', true); } - return ajvInstance -} \ No newline at end of file + return ajvInstance; +}; diff --git a/src/framework/ajv/index.ts b/src/framework/ajv/index.ts index bb297080..97e315d1 100644 --- a/src/framework/ajv/index.ts +++ b/src/framework/ajv/index.ts @@ -1,5 +1,5 @@ import AjvDraft4 from 'ajv-draft-04'; -import Ajv2020 from 'ajv/dist/2020' +import Ajv2020 from 'ajv/dist/2020'; import { DataValidateFunction } from 'ajv/dist/types'; import ajvType from 'ajv/dist/vocabularies/jtd/type'; import addFormats from 'ajv-formats'; @@ -35,15 +35,15 @@ function createAjv( const ajv = factoryAjv(openApiSpec.openapi, { ...ajvOptions, - formats - }) + formats, + }); // Clean openApiSpec - traverse(openApiSpec, { allKeys: true }, (schema => { + traverse(openApiSpec, { allKeys: true }, ((schema) => { if ('x-stoplight' in schema) { - delete schema['x-stoplight'] + delete schema['x-stoplight']; } - })) + })); // Formats will overwrite existing validation, // so set in order of least->most important. @@ -116,12 +116,15 @@ function createAjv( compile: (sch, p, it) => { if (sch) { const validate: DataValidateFunction = (data, ctx) => { - if (options.removeAdditional == true || options.removeAdditional == "all" || options.removeAdditional == "failing") { + if ( + options.removeAdditional == true || + options.removeAdditional == 'all' || + options.removeAdditional == 'failing' + ) { // Remove readonly properties in request delete ctx.parentData[ctx.parentDataProperty]; return true; - } - else { + } else { const isValid = data == null; if (!isValid) { validate.errors = [ @@ -184,12 +187,15 @@ function createAjv( compile: (sch, p, it) => { if (sch) { const validate: DataValidateFunction = (data, ctx) => { - if (options.removeAdditional == true || options.removeAdditional == "all" || options.removeAdditional == "failing") { + if ( + options.removeAdditional == true || + options.removeAdditional == 'all' || + options.removeAdditional == 'failing' + ) { // Remove readonly properties in request delete ctx.parentData[ctx.parentDataProperty]; return true; - } - else { + } else { const isValid = data == null; if (!isValid) { validate.errors = [ @@ -198,7 +204,7 @@ function createAjv( instancePath: ctx.instancePath, schemaPath: it.schemaPath.str, message: `is write-only`, - params: {writeOnly: ctx.parentDataProperty}, + params: { writeOnly: ctx.parentDataProperty }, }, ]; } diff --git a/src/framework/ajv/options.ts b/src/framework/ajv/options.ts index bde6859c..bae60476 100644 --- a/src/framework/ajv/options.ts +++ b/src/framework/ajv/options.ts @@ -30,9 +30,12 @@ export class AjvOptions { } get request(): RequestValidatorOptions { - const { allErrors, allowUnknownQueryParameters, coerceTypes, removeAdditional } = < - ValidateRequestOpts - >this.options.validateRequests; + const { + allErrors, + allowUnknownQueryParameters, + coerceTypes, + removeAdditional, + } = this.options.validateRequests; return { ...this.baseOptions(), allErrors, @@ -47,13 +50,8 @@ export class AjvOptions { } private baseOptions(): Options { - const { - coerceTypes, - formats, - validateFormats, - serDes, - ajvFormats, - } = this.options; + const { coerceTypes, formats, validateFormats, serDes, ajvFormats } = + this.options; const serDesMap = {}; for (const serDesObject of serDes) { if (!serDesMap[serDesObject.format]) { diff --git a/src/framework/base.path.ts b/src/framework/base.path.ts index 1f56e92f..a4319a9f 100644 --- a/src/framework/base.path.ts +++ b/src/framework/base.path.ts @@ -20,9 +20,9 @@ export class BasePath { let urlPath = this.findUrlPath(server.url); if (/:/.test(urlPath)) { // escape colons as (any at this point) do not signify express route params. - // this is an openapi base path, thus route params are wrapped in braces {}, + // this is an openapi base path, thus route params are wrapped in braces {}, // not prefixed by colon : (like express route params) - urlPath = urlPath.replace(':','\\:') + urlPath = urlPath.replace(':', '\\:'); } if (/{\w+}/.test(urlPath)) { // has variable that we need to check out @@ -47,7 +47,7 @@ export class BasePath { if (!servers) { return [new BasePath({ url: '' })]; } - return servers.map(server => new BasePath(server)); + return servers.map((server) => new BasePath(server)); } public hasVariables(): boolean { @@ -61,7 +61,7 @@ export class BasePath { // ignore variables that are not part of path params const allParams = Object.entries(this.variables).reduce((acc, v) => { const [key, value] = v; - const params = value.enum.map(e => ({ + const params = value.enum.map((e) => ({ [key]: e, })); acc.push(params); @@ -70,7 +70,9 @@ export class BasePath { const allParamCombos = cartesian(...allParams); // path-to-regexp v 8.x.x requires we escape the open and close parentheses `(`,`)` added a replace function to catch that use case. - const filteredExpressPath = this.expressPath.replace(/[(]/g, '\\\\(').replace(/[)]/g, '\\\\)'); + const filteredExpressPath = this.expressPath + .replace(/[(]/g, '\\\\(') + .replace(/[)]/g, '\\\\)'); const toPath = compile(filteredExpressPath); const paths = new Set(); for (const combo of allParamCombos) { @@ -81,12 +83,12 @@ export class BasePath { } private findUrlPath(u: string): string { - const findColonSlashSlash = p => { + const findColonSlashSlash = (p) => { const r = /:\/\//.exec(p); if (r) return r.index; return -1; }; - const findFirstSlash = p => { + const findFirstSlash = (p) => { const r = /\//.exec(p); if (r) return r.index; return -1; diff --git a/src/framework/base.serdes.ts b/src/framework/base.serdes.ts index cd65ae48..57eb2a8f 100644 --- a/src/framework/base.serdes.ts +++ b/src/framework/base.serdes.ts @@ -1,26 +1,23 @@ import { SerDes, SerDesSingleton } from './types'; -export const dateTime : SerDesSingleton = new SerDesSingleton({ - format : 'date-time', +export const dateTime: SerDesSingleton = new SerDesSingleton({ + format: 'date-time', serialize: (d: Date) => { return d && d.toISOString(); }, deserialize: (s: string) => { return new Date(s); - } + }, }); -export const date : SerDesSingleton = new SerDesSingleton({ - format : 'date', +export const date: SerDesSingleton = new SerDesSingleton({ + format: 'date', serialize: (d: Date) => { return d && d.toISOString().split('T')[0]; }, deserialize: (s: string) => { return new Date(s); - } + }, }); -export const defaultSerDes : SerDes[] = [ - date.serializer, - dateTime.serializer -]; +export const defaultSerDes: SerDes[] = [date.serializer, dateTime.serializer]; diff --git a/src/framework/index.ts b/src/framework/index.ts index 8fe2ceb9..5f9546cc 100644 --- a/src/framework/index.ts +++ b/src/framework/index.ts @@ -101,7 +101,9 @@ export class OpenAPIFramework { return doc as Promise; } - private sortApiDocTags(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1): void { + private sortApiDocTags( + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, + ): void { if (apiDoc && Array.isArray(apiDoc.tags)) { apiDoc.tags.sort((a, b): number => { return a.name < b.name ? -1 : 1; diff --git a/src/framework/json.ref.schema.ts b/src/framework/json.ref.schema.ts index 8b137891..e69de29b 100644 --- a/src/framework/json.ref.schema.ts +++ b/src/framework/json.ref.schema.ts @@ -1 +0,0 @@ - diff --git a/src/framework/modded.express.mung.ts b/src/framework/modded.express.mung.ts index fc6c0a51..6c774880 100644 --- a/src/framework/modded.express.mung.ts +++ b/src/framework/modded.express.mung.ts @@ -23,7 +23,7 @@ mung.onError = (err, req, res, next) => { }; mung.json = function json(fn, options) { - return function(req, res, next) { + return function (req, res, next) { let original = res.json; options = options || {}; let mungError = options.mungError; @@ -63,7 +63,7 @@ mung.json = function json(fn, options) { }; mung.jsonAsync = function json(fn, options) { - return function(req, res, next) { + return function (req, res, next) { let original = res.json; options = options || {}; let mungError = options.mungError; @@ -75,7 +75,7 @@ mung.jsonAsync = function json(fn, options) { if (!mungError && res.statusCode >= 400) return original.call(this, json); try { fn(json, req, res) - .then(json => { + .then((json) => { if (res.headersSent) return; // If null, then 204 No Content @@ -89,7 +89,7 @@ mung.jsonAsync = function json(fn, options) { return original.call(this, json); }) - .catch(e => mung.onError(e, req, res, next)); + .catch((e) => mung.onError(e, req, res, next)); } catch (e) { mung.onError(e, req, res, next); } @@ -103,7 +103,7 @@ mung.jsonAsync = function json(fn, options) { }; mung.headers = function headers(fn) { - return function(req, res, next) { + return function (req, res, next) { let original = res.end; function headers_hook() { res.end = original; @@ -129,9 +129,9 @@ mung.headers = function headers(fn) { }; mung.headersAsync = function headersAsync(fn) { - return function(req, res, next) { + return function (req, res, next) { let original = res.end; - let onError = e => { + let onError = (e) => { res.end = original; return mung.onError(e, req, res, next); }; @@ -146,7 +146,7 @@ mung.headersAsync = function headersAsync(fn) { if (res.headersSent) return; original.apply(this, args); }) - .catch(e => onError(e)); + .catch((e) => onError(e)); } catch (e) { onError(e); } @@ -158,7 +158,7 @@ mung.headersAsync = function headersAsync(fn) { }; mung.write = function write(fn, options: any = {}) { - return function(req, res, next) { + return function (req, res, next) { const original = res.write; const mungError = options.mungError; diff --git a/src/framework/openapi.context.ts b/src/framework/openapi.context.ts index eab583d7..c04f00cf 100644 --- a/src/framework/openapi.context.ts +++ b/src/framework/openapi.context.ts @@ -42,7 +42,9 @@ export class OpenApiContext { } public shouldIgnoreRoute(path: string) { - return typeof this.ignorePaths === 'function' ? this.ignorePaths(path) : this.ignorePaths?.test(path); + return typeof this.ignorePaths === 'function' + ? this.ignorePaths(path) + : this.ignorePaths?.test(path); } public routePair(route: string): RoutePair { diff --git a/src/framework/openapi.schema.validator.ts b/src/framework/openapi.schema.validator.ts index 3da4b035..b2c1a559 100644 --- a/src/framework/openapi.schema.validator.ts +++ b/src/framework/openapi.schema.validator.ts @@ -1,8 +1,4 @@ -import { - ErrorObject, - Options, - ValidateFunction, -} from 'ajv-draft-04'; +import { ErrorObject, Options, ValidateFunction } from 'ajv-draft-04'; import addFormats from 'ajv-formats'; import { OpenAPIV3 } from './types.js'; import { factoryAjv } from './ajv/factory'; @@ -28,8 +24,8 @@ export class OpenAPISchemaValidator { options.validateSchema = false; } - const ajvInstance = factoryAjv(opts.version, options) - const schema = factorySchema(opts.version) + const ajvInstance = factoryAjv(opts.version, options); + const schema = factorySchema(opts.version); addFormats(ajvInstance, ['email', 'regex', 'uri', 'uri-reference']); diff --git a/src/framework/openapi.spec.loader.ts b/src/framework/openapi.spec.loader.ts index 9ce6cbee..b43d95ef 100644 --- a/src/framework/openapi.spec.loader.ts +++ b/src/framework/openapi.spec.loader.ts @@ -77,16 +77,16 @@ export class OpenApiSpecLoader { ...(schema.parameters ?? []), ...(methods.parameters ?? []), ] - .map(param => dereferenceParameter(apiDoc, param)) - .filter(param => param.in === 'path') - .map(param => param.name); + .map((param) => dereferenceParameter(apiDoc, param)) + .filter((param) => param.in === 'path') + .map((param) => param.name); const openApiRoute = `${bp}${path}`; const expressRoute = `${openApiRoute}` .split(':') .map(toExpressParams) .join('\\:'); - + routes.push({ basePath: bp, expressRoute, @@ -108,7 +108,7 @@ export class OpenApiSpecLoader { apiDoc, basePaths, routes, - serial + serial, }; } @@ -118,7 +118,7 @@ export class OpenApiSpecLoader { // const pass1 = part.replace(/\{(\/)([^\*]+)(\*)}/g, '$1:$2$3'); //if wildcard path use new path-to-regex expected model - if(/[*]/g.test(part)){ + if (/[*]/g.test(part)) { // /v1/{path}* => /v1/*path) // /v1/{path}(*) => /v1/*path) const pass1 = part.replace(/\/{([^}]+)}\({0,1}(\*)\){0,1}/g, '/$2$1'); diff --git a/src/framework/openapi/assert.version.ts b/src/framework/openapi/assert.version.ts index f5c6e05e..21d7a37c 100644 --- a/src/framework/openapi/assert.version.ts +++ b/src/framework/openapi/assert.version.ts @@ -1,19 +1,19 @@ /** * Asserts open api version - * + * * @param openApiVersion SemVer version * @returns destructured major and minor */ export const assertVersion = (openApiVersion: string) => { const [ok, major, minor] = /^(\d+)\.(\d+).(\d+)?$/.exec(openApiVersion); - - if (!ok) { - throw Error('Version missing from OpenAPI specification') - }; - if (major !== '3' || minor !== '0' && minor !== '1') { + if (!ok) { + throw Error('Version missing from OpenAPI specification'); + } + + if (major !== '3' || (minor !== '0' && minor !== '1')) { throw new Error('OpenAPI v3.0 or v3.1 specification version is required'); } - return { major, minor } -} \ No newline at end of file + return { major, minor }; +}; diff --git a/src/framework/openapi/factory.schema.ts b/src/framework/openapi/factory.schema.ts index 2c78e1a0..33ded3d6 100644 --- a/src/framework/openapi/factory.schema.ts +++ b/src/framework/openapi/factory.schema.ts @@ -1,4 +1,4 @@ -import { assertVersion } from "./assert.version"; +import { assertVersion } from './assert.version'; // https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v3.0/schema.json import * as openapi3Schema from '../openapi.v3.schema.json'; @@ -11,6 +11,6 @@ export const factorySchema = (version: string): Object => { if (minor === '0') { return openapi3Schema; } - - return openapi31Schema -} \ No newline at end of file + + return openapi31Schema; +}; diff --git a/src/framework/types.ts b/src/framework/types.ts index b75adc31..d533aa17 100644 --- a/src/framework/types.ts +++ b/src/framework/types.ts @@ -7,7 +7,7 @@ import AjvDraft4 from 'ajv-draft-04'; import Ajv2020 from 'ajv/dist/2020'; export { OpenAPIFrameworkArgs }; -export type AjvInstance = AjvDraft4 | Ajv2020 +export type AjvInstance = AjvDraft4 | Ajv2020; export type BodySchema = | OpenAPIV3.ReferenceObject @@ -48,7 +48,7 @@ export interface Options extends ajv.Options { ajvFormats?: FormatsPluginOptions; } -export interface RequestValidatorOptions extends Options, ValidateRequestOpts { } +export interface RequestValidatorOptions extends Options, ValidateRequestOpts {} export type ValidateRequestOpts = { /** @@ -125,32 +125,42 @@ export class SerDesSingleton implements SerDes { serialize: param.serialize, }; } -}; +} export type SerDesMap = { - [format: string]: SerDes + [format: string]: SerDes; }; -type Primitive = undefined | null | boolean | string | number | Function +type Primitive = undefined | null | boolean | string | number | Function; -type Immutable = - T extends Primitive ? T : - T extends Array ? ReadonlyArray : - T extends Map ? ReadonlyMap : Readonly +type Immutable = T extends Primitive + ? T + : T extends Array + ? ReadonlyArray + : T extends Map + ? ReadonlyMap + : Readonly; -type DeepImmutable = - T extends Primitive ? T : - T extends Array ? DeepImmutableArray : - T extends Map ? DeepImmutableMap : DeepImmutableObject +type DeepImmutable = T extends Primitive + ? T + : T extends Array + ? DeepImmutableArray + : T extends Map + ? DeepImmutableMap + : DeepImmutableObject; interface DeepImmutableArray extends ReadonlyArray> {} -interface DeepImmutableMap extends ReadonlyMap, DeepImmutable> {} +interface DeepImmutableMap + extends ReadonlyMap, DeepImmutable> {} type DeepImmutableObject = { - readonly [K in keyof T]: DeepImmutable -} + readonly [K in keyof T]: DeepImmutable; +}; export interface OpenApiValidatorOpts { - apiSpec: DeepImmutable | DeepImmutable | string; + apiSpec: + | DeepImmutable + | DeepImmutable + | string; validateApiSpec?: boolean; validateResponses?: boolean | ValidateResponseOpts; validateRequests?: boolean | ValidateRequestOpts; @@ -205,17 +215,18 @@ export namespace OpenAPIV3 { } interface ComponentsV3_1 extends ComponentsObject { - pathItems?: { [path: string]: PathItemObject | ReferenceObject } + pathItems?: { [path: string]: PathItemObject | ReferenceObject }; } - export interface DocumentV3_1 extends Omit { + export interface DocumentV3_1 + extends Omit { openapi: `3.1.${string}`; paths?: DocumentV3['paths']; info: InfoObjectV3_1; components: ComponentsV3_1; webhooks: { - [name: string]: PathItemObject | ReferenceObject - } + [name: string]: PathItemObject | ReferenceObject; + }; } export interface InfoObject { @@ -299,7 +310,7 @@ export namespace OpenAPIV3 { in: string; } - export interface HeaderObject extends ParameterBaseObject { } + export interface HeaderObject extends ParameterBaseObject {} interface ParameterBaseObject { description?: string; @@ -323,14 +334,18 @@ export namespace OpenAPIV3 { | 'integer'; export type ArraySchemaObjectType = 'array'; - export type SchemaObject = ArraySchemaObject | NonArraySchemaObject | CompositionSchemaObject; + export type SchemaObject = + | ArraySchemaObject + | NonArraySchemaObject + | CompositionSchemaObject; - export interface ArraySchemaObject extends BaseSchemaObject { + export interface ArraySchemaObject + extends BaseSchemaObject { items: ReferenceObject | SchemaObject; } - export interface NonArraySchemaObject extends BaseSchemaObject { - } + export interface NonArraySchemaObject + extends BaseSchemaObject {} export interface CompositionSchemaObject extends BaseSchemaObject { // JSON schema allowed properties, adjusted for OpenAPI diff --git a/src/middlewares/openapi.metadata.ts b/src/middlewares/openapi.metadata.ts index ee576b0e..587dabf1 100644 --- a/src/middlewares/openapi.metadata.ts +++ b/src/middlewares/openapi.metadata.ts @@ -71,7 +71,9 @@ export function applyOpenApiMetadata( req: OpenApiRequest, useRequestUrl: boolean, ): OpenApiRequestMetadata { - const path = useRequestUrl ? req.url.split('?')[0] : req.originalUrl.split('?')[0]; + const path = useRequestUrl + ? req.url.split('?')[0] + : req.originalUrl.split('?')[0]; const method = req.method; const routeEntries = Object.entries(openApiContext.expressRouteMap); for (const [expressRoute, methods] of routeEntries) { diff --git a/src/middlewares/openapi.multipart.ts b/src/middlewares/openapi.multipart.ts index 97a5fc47..f1f52518 100644 --- a/src/middlewares/openapi.multipart.ts +++ b/src/middlewares/openapi.multipart.ts @@ -42,7 +42,7 @@ export function multipart( // // This is a bit complex because the schema may be defined inline (easy) or via a $ref (complex) in which // case we must follow the $ref to check the type. - + if (req.files) { // to handle single and multiple file upload at the same time, let us this initialize this count variable // for example { "files": 5 } @@ -52,7 +52,7 @@ export function multipart( acc[curr] = (acc[curr] || 0) + 1; return acc; }, {}); - + // add file(s) to body Object.entries(count_by_fieldname).forEach( ([fieldname, count]: [string, number]) => { @@ -68,7 +68,7 @@ export function multipart( } }); }); - next() + next(); } catch (error) { next(error); } diff --git a/src/middlewares/openapi.request.validator.ts b/src/middlewares/openapi.request.validator.ts index c675e0d6..cb4de75d 100644 --- a/src/middlewares/openapi.request.validator.ts +++ b/src/middlewares/openapi.request.validator.ts @@ -343,8 +343,12 @@ class Security { apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, schema: OperationObject, ): string[] { - const hasPathSecurity = schema.security ? schema.security.length > 0 : false; - const hasRootSecurity = apiDocs.security ? apiDocs.security.length > 0 : false; + const hasPathSecurity = schema.security + ? schema.security.length > 0 + : false; + const hasRootSecurity = apiDocs.security + ? apiDocs.security.length > 0 + : false; let usedSecuritySchema: SecurityRequirementObject[] = []; if (hasPathSecurity) { diff --git a/src/middlewares/openapi.security.ts b/src/middlewares/openapi.security.ts index 64456183..4accd534 100644 --- a/src/middlewares/openapi.security.ts +++ b/src/middlewares/openapi.security.ts @@ -24,21 +24,31 @@ interface SecurityHandlerResult { error?: string; } -function extractErrorsFromResults(results: (SecurityHandlerResult | SecurityHandlerResult[])[]) { - return results.map(result => { - if (Array.isArray(result)) { - return result.map(it => it).filter(it => !it.success); - } - return [result].filter(it => !it.success); - }).flatMap(it => [...it]); +function extractErrorsFromResults( + results: (SecurityHandlerResult | SecurityHandlerResult[])[], +) { + return results + .map((result) => { + if (Array.isArray(result)) { + return result.map((it) => it).filter((it) => !it.success); + } + return [result].filter((it) => !it.success); + }) + .flatMap((it) => [...it]); } function didAllSecurityRequirementsPass(results: SecurityHandlerResult[]) { - return results.every(it => it.success); + return results.every((it) => it.success); } -function didOneSchemaPassValidation(results: (SecurityHandlerResult | SecurityHandlerResult[])[]) { - return results.some(result => Array.isArray(result) ? didAllSecurityRequirementsPass(result) : result.success); +function didOneSchemaPassValidation( + results: (SecurityHandlerResult | SecurityHandlerResult[])[], +) { + return results.some((result) => + Array.isArray(result) + ? didAllSecurityRequirementsPass(result) + : result.success, + ); } export function security( @@ -235,13 +245,13 @@ class AuthValidator { // req.cookies will be `undefined` without `cookie-parser` middleware const authCookie = req.cookies?.[scheme.name] || req.signedCookies?.[scheme.name]; - + const type = scheme.scheme && scheme.scheme.toLowerCase(); if (type === 'bearer') { if (authHeader && !authHeader.includes('bearer')) { throw Error(`Authorization header with scheme 'Bearer' required`); } - + if (!authHeader && !authCookie) { if (scheme.in === 'cookie') { throw Error(`Cookie authentication required`); @@ -250,7 +260,7 @@ class AuthValidator { } } } - + if (type === 'basic') { if (!authHeader) { throw Error(`Authorization header required`); diff --git a/src/middlewares/parsers/body.parse.ts b/src/middlewares/parsers/body.parse.ts index 324aa313..317efe3b 100644 --- a/src/middlewares/parsers/body.parse.ts +++ b/src/middlewares/parsers/body.parse.ts @@ -7,8 +7,7 @@ import { } from '../../framework/types'; export class BodySchemaParser { - constructor() { - } + constructor() {} public parse( path: string, pathSchema: OpenAPIV3.OperationObject, @@ -44,7 +43,11 @@ export class BodySchemaParser { const equivalentContentTypes = contentType.equivalents(); for (const type of requestBodyTypes) { let openApiContentType = ContentType.fromString(type); - if (equivalentContentTypes.find((type2) => openApiContentType.normalize() === type2.normalize())) { + if ( + equivalentContentTypes.find( + (type2) => openApiContentType.normalize() === type2.normalize(), + ) + ) { content = requestBody.content[type]; break; } @@ -74,13 +77,15 @@ export class BodySchemaParser { if (!content) { // check if required is false, if so allow request when no content type is supplied const contentNotProvided = contentType.normalize() === 'not_provided'; - if ((contentType.normalize() === undefined || contentNotProvided) && requestBody.required === false) { + if ( + (contentType.normalize() === undefined || contentNotProvided) && + requestBody.required === false + ) { return {}; } - const msg = - contentNotProvided - ? 'media type not specified' - : `unsupported media type ${contentType.normalize()}`; + const msg = contentNotProvided + ? 'media type not specified' + : `unsupported media type ${contentType.normalize()}`; throw new UnsupportedMediaType({ path: path, message: msg }); } return content.schema ?? {}; diff --git a/src/middlewares/parsers/req.parameter.mutator.ts b/src/middlewares/parsers/req.parameter.mutator.ts index 43da1f96..73ca48a1 100644 --- a/src/middlewares/parsers/req.parameter.mutator.ts +++ b/src/middlewares/parsers/req.parameter.mutator.ts @@ -76,10 +76,20 @@ export class RequestParameterMutator { const i = req.originalUrl.indexOf('?'); const queryString = req.originalUrl.substr(i + 1); - if (parameter.in === 'query' && !parameter.allowReserved && !!parameter.explode) { //} && !!parameter.explode) { + if ( + parameter.in === 'query' && + !parameter.allowReserved && + !!parameter.explode + ) { + //} && !!parameter.explode) { this.validateReservedCharacters(name, rawQuery); } - if (parameter.in === 'query' && !parameter.allowReserved && !parameter.explode) { //} && !!parameter.explode) { + if ( + parameter.in === 'query' && + !parameter.allowReserved && + !parameter.explode + ) { + //} && !!parameter.explode) { this.validateReservedCharacters(name, rawQuery, true); } @@ -97,7 +107,13 @@ export class RequestParameterMutator { } else if (type === 'array' && !explode) { const delimiter = ARRAY_DELIMITER[parameter.style]; this.validateArrayDelimiter(delimiter, parameter); - this.parseJsonArrayAndMutateRequest(req, parameter.in, name, delimiter, rawQuery); + this.parseJsonArrayAndMutateRequest( + req, + parameter.in, + name, + delimiter, + rawQuery, + ); } else if (type === 'array' && explode) { this.explodeJsonArrayAndMutateRequest(req, parameter.in, name); } else if (style === 'form' && explode) { @@ -190,8 +206,8 @@ export class RequestParameterMutator { const properties = hasXOf ? xOfProperties(schema) : type === 'object' - ? Object.keys(schema.properties ?? {}) - : []; + ? Object.keys(schema.properties ?? {}) + : []; this.explodedJsonObjectAndMutateRequest( req, @@ -266,7 +282,7 @@ export class RequestParameterMutator { * filter=foo%20bar%20baz */ const field = REQUEST_FIELDS[$in]; - const rawValues = [] + const rawValues = []; if (['query'].includes($in)) { // perhaps split query from params rawValues.concat(rawQuery.get(name) ?? []); @@ -277,11 +293,14 @@ export class RequestParameterMutator { if (Array.isArray(req[field][name])) return; const value = req[field][name].split(delimiter); const rawValue = rawValues[i++]; - if (rawValue?.includes(delimiter)) { // TODO add && !allowReserved to improve performance. When allowReserved is true, commas are common and we do not need to do this extra work + if (rawValue?.includes(delimiter)) { + // TODO add && !allowReserved to improve performance. When allowReserved is true, commas are common and we do not need to do this extra work // Currently, rawValue is only populated for query params // if the raw value contains a delimiter, decode manually // parse the decode value and update req[field][name] - const manuallyDecodedValues = rawValue.split(delimiter).map(v => decodeURIComponent(v)); + const manuallyDecodedValues = rawValue + .split(delimiter) + .map((v) => decodeURIComponent(v)); req[field][name] = manuallyDecodedValues; } else { req[field][name] = value; diff --git a/src/middlewares/parsers/schema.parse.ts b/src/middlewares/parsers/schema.parse.ts index fb5d380c..c23558ca 100644 --- a/src/middlewares/parsers/schema.parse.ts +++ b/src/middlewares/parsers/schema.parse.ts @@ -19,7 +19,10 @@ export class ParametersSchemaParser { private _ajv: Ajv; private _apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; - constructor(ajv: Ajv, apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { + constructor( + ajv: Ajv, + apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, + ) { this._ajv = ajv; this._apiDocs = apiDocs; } diff --git a/src/middlewares/parsers/schema.preprocessor.ts b/src/middlewares/parsers/schema.preprocessor.ts index b6f756e8..d56ac256 100644 --- a/src/middlewares/parsers/schema.preprocessor.ts +++ b/src/middlewares/parsers/schema.preprocessor.ts @@ -44,16 +44,24 @@ class Node { } type SchemaObjectNode = Node; -function isParameterObject(node: ParameterObject | ReferenceObject): node is ParameterObject { - return !((node as ReferenceObject).$ref); +function isParameterObject( + node: ParameterObject | ReferenceObject, +): node is ParameterObject { + return !(node as ReferenceObject).$ref; } -function isReferenceObject(node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject): node is ReferenceObject { - return !!((node as ReferenceObject).$ref); +function isReferenceObject( + node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject, +): node is ReferenceObject { + return !!(node as ReferenceObject).$ref; } -function isArraySchemaObject(node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject): node is ArraySchemaObject { - return !!((node as ArraySchemaObject).items); +function isArraySchemaObject( + node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject, +): node is ArraySchemaObject { + return !!(node as ArraySchemaObject).items; } -function isNonArraySchemaObject(node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject): node is NonArraySchemaObject { +function isNonArraySchemaObject( + node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject, +): node is NonArraySchemaObject { return !isArraySchemaObject(node) && !isReferenceObject(node); } @@ -161,7 +169,7 @@ export class SchemaPreprocessor { // Since OpenAPI 3.1, paths can be a #ref to reusable path items // The following line mutates the paths item to dereference the reference, so that we can process as a POJO, as we would if it wasn't a reference this.apiDoc.paths[p] = pathItem; - + for (const method of Object.keys(pathItem)) { if (httpMethods.has(method)) { const operation = pathItem[method]; @@ -171,7 +179,8 @@ export class SchemaPreprocessor { const node = new Root(operation, path); const requestBodies = this.extractRequestBodySchemaNodes(node); const responseBodies = this.extractResponseSchemaNodes(node); - const requestParameters = this.extractRequestParameterSchemaNodes(node); + const requestParameters = + this.extractRequestParameterSchemaNodes(node); requestBodySchemas.push(...requestBodies); responseSchemas.push(...responseBodies); @@ -244,7 +253,10 @@ export class SchemaPreprocessor { recurse(node, child, opts); }); } else if (schema.additionalProperties) { - const child = new Node(node, schema.additionalProperties, [...node.path, 'additionalProperties']); + const child = new Node(node, schema.additionalProperties, [ + ...node.path, + 'additionalProperties', + ]); recurse(node, child, opts); } }; @@ -300,7 +312,7 @@ export class SchemaPreprocessor { this.handleReadonly(pschema, nschema, options); this.handleWriteonly(pschema, nschema, options); this.processDiscriminator(pschema, nschema, options); - this.removeExamples(pschema, nschema, options) + this.removeExamples(pschema, nschema, options); } } } @@ -463,10 +475,10 @@ export class SchemaPreprocessor { ) { if (schema.type !== 'object') return; if (schema?.example) { - delete schema.example + delete schema.example; } if (schema?.examples) { - delete schema.examples + delete schema.examples; } } @@ -584,21 +596,20 @@ export class SchemaPreprocessor { private extractRequestParameterSchemaNodes( operationNode: Root, ): Root[] { - return (operationNode.schema.parameters ?? []).flatMap((node) => { const parameterObject = isParameterObject(node) ? node : undefined; if (!parameterObject?.schema) return []; - const schema = isNonArraySchemaObject(parameterObject.schema) ? - parameterObject.schema : - undefined; + const schema = isNonArraySchemaObject(parameterObject.schema) + ? parameterObject.schema + : undefined; if (!schema) return []; return new Root(schema, [ ...operationNode.path, 'parameters', parameterObject.name, - parameterObject.in + parameterObject.in, ]); }); } diff --git a/src/middlewares/util.ts b/src/middlewares/util.ts index 991d4a80..812504bb 100644 --- a/src/middlewares/util.ts +++ b/src/middlewares/util.ts @@ -5,11 +5,14 @@ import { ValidationError } from '../framework/types'; export class ContentType { public readonly mediaType: string = null; public readonly isWildCard: boolean; - public readonly parameters: { charset?: string, boundary?: string } & Record = {}; + public readonly parameters: { charset?: string; boundary?: string } & Record< + string, + string + > = {}; private constructor(contentType: string | null) { if (contentType) { const parameterRegExp = /;\s*([^=]+)=([^;]+)/g; - const paramMatches = contentType.matchAll(parameterRegExp) + const paramMatches = contentType.matchAll(parameterRegExp); if (paramMatches) { this.parameters = {}; for (let match of paramMatches) { @@ -22,7 +25,7 @@ export class ContentType { value = value.toLowerCase(); } this.parameters[key] = value; - }; + } } this.mediaType = contentType.split(';')[0].toLowerCase().trim(); this.isWildCard = RegExp(/^[a-z]+\/\*$/).test(contentType); @@ -44,7 +47,9 @@ export class ContentType { types.push(new ContentType(this.mediaType)); if (!this.parameters['charset']) { - types.push(new ContentType(`${this.normalize(['charset'])}; charset=utf-8`)); + types.push( + new ContentType(`${this.normalize(['charset'])}; charset=utf-8`), + ); } return types; } @@ -55,11 +60,10 @@ export class ContentType { .sort() .forEach((key) => { if (!excludeParams.includes(key)) { - parameters += `; ${key}=${this.parameters[key]}` + parameters += `; ${key}=${this.parameters[key]}`; } }); - if (this.mediaType) - return this.mediaType + parameters; + if (this.mediaType) return this.mediaType + parameters; } } @@ -130,10 +134,10 @@ export const findResponseContent = function ( expectedTypes: string[], ): string { const expectedTypesMap = new Map(); - for(let type of expectedTypes) { + for (let type of expectedTypes) { expectedTypesMap.set(ContentType.fromString(type).normalize(), type); } - + // if accepts are supplied, try to find a match, and use its validator for (const accept of accepts) { const act = ContentType.fromString(accept); @@ -167,7 +171,6 @@ export const findResponseContent = function ( export const zipObject = (keys, values) => keys.reduce((acc, key, idx) => { - acc[key] = values[idx] - return acc - }, {}) - + acc[key] = values[idx]; + return acc; + }, {}); diff --git a/src/openapi.validator.ts b/src/openapi.validator.ts index 047c9a97..083be35f 100644 --- a/src/openapi.validator.ts +++ b/src/openapi.validator.ts @@ -36,9 +36,9 @@ export { } from './framework/types'; interface MiddlewareContext { - context: OpenApiContext, - responseApiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, - error: any, + context: OpenApiContext; + responseApiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; + error: any; } export class OpenApiValidator { @@ -208,7 +208,9 @@ export class OpenApiValidator { middlewares.push(function responseMiddleware(req, res, next) { return pContext .then(({ responseApiDoc, context: { serial } }) => { - resmw = resmw || self.responseValidationMiddleware(responseApiDoc, serial); + resmw = + resmw || + self.responseValidationMiddleware(responseApiDoc, serial); return resmw(req, res, next); }) .catch(next); @@ -221,7 +223,9 @@ export class OpenApiValidator { middlewares.push(function operationHandlersMiddleware(req, res, next) { if (router) return router(req, res, next); return pContext - .then(({context}) => self.installOperationHandlers(req.baseUrl, context)) + .then(({ context }) => + self.installOperationHandlers(req.baseUrl, context), + ) .then((installedRouter) => (router = installedRouter)(req, res, next)) .catch(next); }); @@ -239,7 +243,7 @@ export class OpenApiValidator { } // install param on routes with paths - const uniqPathParams = [...new Set(pathParams)] + const uniqPathParams = [...new Set(pathParams)]; for (const p of uniqPathParams) { app.param( p, @@ -269,21 +273,27 @@ export class OpenApiValidator { return middlewares.applyOpenApiMetadata(context, responseApiDoc); } - private multipartMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { + private multipartMiddleware( + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, + ) { return middlewares.multipart(apiDoc, { multerOpts: this.options.fileUploader, ajvOpts: this.ajvOpts.multipart, }); } - private securityMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { + private securityMiddleware( + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, + ) { const securityHandlers = (( this.options.validateSecurity ))?.handlers; return middlewares.security(apiDoc, securityHandlers); } - private requestValidationMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { + private requestValidationMiddleware( + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, + ) { const requestValidator = new middlewares.RequestValidator( apiDoc, this.ajvOpts.request, @@ -291,17 +301,23 @@ export class OpenApiValidator { return (req, res, next) => requestValidator.validate(req, res, next); } - private responseValidationMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, serial: number) { + private responseValidationMiddleware( + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, + serial: number, + ) { return new middlewares.ResponseValidator( apiDoc, this.ajvOpts.response, // This has already been converted from boolean if required this.options.validateResponses as ValidateResponseOpts, - serial + serial, ).validate(); } - async installOperationHandlers(baseUrl: string, context: OpenApiContext): Promise { + async installOperationHandlers( + baseUrl: string, + context: OpenApiContext, + ): Promise { const router = express.Router({ mergeParams: true }); this.installPathParams(router, context); diff --git a/src/resolvers.ts b/src/resolvers.ts index 18aba622..e39a1150 100644 --- a/src/resolvers.ts +++ b/src/resolvers.ts @@ -35,7 +35,10 @@ export function defaultResolver( tmpModules[modulePath] = require(modulePath); } - const handler = tmpModules[modulePath][oId] || tmpModules[modulePath].default[oId] || tmpModules[modulePath].default; + const handler = + tmpModules[modulePath][oId] || + tmpModules[modulePath].default[oId] || + tmpModules[modulePath].default; if (!handler) { throw Error( diff --git a/test/1022.spec.ts b/test/1022.spec.ts index 0c770fa9..4d1afbe4 100644 --- a/test/1022.spec.ts +++ b/test/1022.spec.ts @@ -157,7 +157,5 @@ describe(packageJson.name, () => { })); it('GET /some/test with wildcard should return 200', async () => - request(app) - .get(`/api/some/test/stuff`) - .expect(200)); + request(app).get(`/api/some/test/stuff`).expect(200)); }); diff --git a/test/356.campaign.spec.ts b/test/356.campaign.spec.ts index fbe834db..57004cd5 100644 --- a/test/356.campaign.spec.ts +++ b/test/356.campaign.spec.ts @@ -1,4 +1,4 @@ - import * as path from 'path'; +import * as path from 'path'; import * as express from 'express'; import * as request from 'supertest'; import { createApp } from './common/app'; diff --git a/test/356.campaign.yaml b/test/356.campaign.yaml index 0f01a687..cae88114 100644 --- a/test/356.campaign.yaml +++ b/test/356.campaign.yaml @@ -69,8 +69,8 @@ components: endDate: type: string format: date-time - example: - type: string + example: + type: string example: name: 'hi' - description: 'yo' \ No newline at end of file + description: 'yo' diff --git a/test/440.spec.ts b/test/440.spec.ts index 50960245..d2b55939 100644 --- a/test/440.spec.ts +++ b/test/440.spec.ts @@ -45,16 +45,19 @@ describe(packageJson.name, () => { }, }, }; - app = await createApp({ - apiSpec, - validateRequests: true, - validateResponses: true, - }, 3005, (app) => - app.use( - express - .Router() - .post(`/test/abc123`, (req, res) => res.status(200).json(req.body)), - ), + app = await createApp( + { + apiSpec, + validateRequests: true, + validateResponses: true, + }, + 3005, + (app) => + app.use( + express + .Router() + .post(`/test/abc123`, (req, res) => res.status(200).json(req.body)), + ), ); }); diff --git a/test/577.spec.ts b/test/577.spec.ts index a142d45a..49d0a139 100644 --- a/test/577.spec.ts +++ b/test/577.spec.ts @@ -13,7 +13,7 @@ describe('#577 - Exclude response validation that is not in api spec', () => { const app = await createApp(apiSpec); await request(app).get('/users').expect(200, 'some users'); await request(app).post('/users').expect(201, 'Created!'); - await request(app).get ('/example').expect(200, 'Example indeed') + await request(app).get('/example').expect(200, 'Example indeed'); app.server.close(); deepStrictEqual(apiSpec, createApiSpec()); @@ -34,18 +34,15 @@ async function createApp( }), ); app.get('/users', (req, res) => { - res.status(200).send('some users'); - } - ); + res.status(200).send('some users'); + }); app.post('/users', (req, res) => { - res.status(201).send('Created!'); - } - ); + res.status(201).send('Created!'); + }); app.get('/example', (req, res) => { - res.status(200).send('Example indeed'); - } - ); + res.status(200).send('Example indeed'); + }); await startServer(app, 3001); return app; diff --git a/test/699.spec.ts b/test/699.spec.ts index 4e3399e2..7b85d31d 100644 --- a/test/699.spec.ts +++ b/test/699.spec.ts @@ -10,19 +10,18 @@ const apiSpecPath = path.join('test', 'resources', '699.yaml'); class ObjectID { id: string; - constructor(id: string = "5fdefd13a6640bb5fb5fa925") { + constructor(id: string = '5fdefd13a6640bb5fb5fa925') { this.id = id; } toString() { return this.id; } - } class BadDate extends Date { public toISOString(): string { - return "oh no a bad iso date"; + return 'oh no a bad iso date'; } } @@ -35,16 +34,16 @@ describe('699', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true + coerceTypes: true, }, validateResponses: { - coerceTypes: true + coerceTypes: true, }, serDes: [ date, dateTime, { - format: "mongo-objectid", + format: 'mongo-objectid', deserialize: (s) => new ObjectID(s), serialize: (o) => o.toString(), }, @@ -55,9 +54,9 @@ describe('699', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'object') { - throw new Error("Should be deserialized to ObjectId object"); + throw new Error('Should be deserialized to ObjectId object'); } - let date = new Date("2020-12-20T07:28:19.213Z"); + let date = new Date('2020-12-20T07:28:19.213Z'); res.json({ id: req.params.id, creationDateTime: date, @@ -68,11 +67,18 @@ describe('699', () => { }); }); app.post([`${app.basePath}/users`], (req, res) => { - if (typeof req.body.history[0].modificationDate !== 'object' || !(req.body.history[0].modificationDate instanceof Date)) { - throw new Error("Should be deserialized to Date object"); + if ( + typeof req.body.history[0].modificationDate !== 'object' || + !(req.body.history[0].modificationDate instanceof Date) + ) { + throw new Error('Should be deserialized to Date object'); } - if (typeof req.body.historyWithoutRef[0].modificationDate !== 'object' || !(req.body.historyWithoutRef[0].modificationDate instanceof Date)) { - throw new Error("Should be deserialized to Date object"); + if ( + typeof req.body.historyWithoutRef[0].modificationDate !== + 'object' || + !(req.body.historyWithoutRef[0].modificationDate instanceof Date) + ) { + throw new Error('Should be deserialized to Date object'); } res.json(req.body); }); @@ -85,7 +91,7 @@ describe('699', () => { }, false, ); - return app + return app; }); after(() => { @@ -97,8 +103,10 @@ describe('699', () => { .get(`${app.basePath}/users/5fdefd13a6640bb5fb5fa925`) .expect(200) .then((r) => { - expect(r.body.history[0].modificationDate).to.equal("2020-12-20"); - expect(r.body.historyWithoutRef[0].modificationDate).to.equal("2020-12-20"); + expect(r.body.history[0].modificationDate).to.equal('2020-12-20'); + expect(r.body.historyWithoutRef[0].modificationDate).to.equal( + '2020-12-20', + ); })); it('should POST also works with deserialize on request then serialize en response', async () => @@ -115,8 +123,10 @@ describe('699', () => { .set('Content-Type', 'application/json') .expect(200) .then((r) => { - expect(r.body.history[0].modificationDate).to.equal("2020-12-20"); - expect(r.body.historyWithoutRef[0].modificationDate).to.equal("2020-12-20"); + expect(r.body.history[0].modificationDate).to.equal('2020-12-20'); + expect(r.body.historyWithoutRef[0].modificationDate).to.equal( + '2020-12-20', + ); })); it('should POST throw error on invalid schema Date', async () => @@ -132,7 +142,9 @@ describe('699', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/history/0/modificationDate must match format "date"'); + expect(r.body.message).to.equal( + 'request/body/history/0/modificationDate must match format "date"', + ); })); it('should POST throw error on invalid schema Date', async () => @@ -148,13 +160,12 @@ describe('699', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/historyWithoutRef/0/modificationDate must match format "date"'); + expect(r.body.message).to.equal( + 'request/body/historyWithoutRef/0/modificationDate must match format "date"', + ); })); - }); - - describe('699 serialize response components only', () => { let app = null; @@ -164,16 +175,16 @@ describe('699 serialize response components only', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true + coerceTypes: true, }, validateResponses: { - coerceTypes: true + coerceTypes: true, }, serDes: [ date.serializer, dateTime.serializer, { - format: "mongo-objectid", + format: 'mongo-objectid', serialize: (o) => o.toString(), }, ], @@ -183,9 +194,9 @@ describe('699 serialize response components only', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'string') { - throw new Error("Should be not be deserialized to ObjectId object"); + throw new Error('Should be not be deserialized to ObjectId object'); } - let date = new Date("2020-12-20T07:28:19.213Z"); + let date = new Date('2020-12-20T07:28:19.213Z'); let result = { id: new ObjectID(req.params.id), creationDateTime: date, @@ -197,20 +208,20 @@ describe('699 serialize response components only', () => { if (req.query.baddateresponse === 'functionNotExists') { result.history[0].modificationDate = new ObjectID(); result.historyWithoutRef[0].modificationDate = date; - } - else if (req.query.baddateresponse === 'functionNotExistsWithoutRef') { + } else if ( + req.query.baddateresponse === 'functionNotExistsWithoutRef' + ) { result.history[0].modificationDate = date; result.historyWithoutRef[0].modificationDate = new ObjectID(); - } - else if (req.query.baddateresponse === 'functionBadFormat') { + } else if (req.query.baddateresponse === 'functionBadFormat') { result.history[0].modificationDate = new BadDate(); result.historyWithoutRef[0].modificationDate = date; - } - else if (req.query.baddateresponse === 'functionBadFormatWithoutRef') { + } else if ( + req.query.baddateresponse === 'functionBadFormatWithoutRef' + ) { result.history[0].modificationDate = date; result.historyWithoutRef[0].modificationDate = new BadDate(); - } - else { + } else { result.history[0].modificationDate = date; result.historyWithoutRef[0].modificationDate = date; } @@ -218,18 +229,24 @@ describe('699 serialize response components only', () => { }); app.post([`${app.basePath}/users`], (req, res) => { if (typeof req.body.id !== 'string') { - throw new Error("Should NOT be deserialized to ObjectId object"); + throw new Error('Should NOT be deserialized to ObjectId object'); } if (typeof req.body.history[0].modificationDate !== 'string') { - throw new Error("Should NTO be deserialized to Date object"); + throw new Error('Should NTO be deserialized to Date object'); } - if (typeof req.body.historyWithoutRef[0].modificationDate !== 'string') { - throw new Error("Should NOT be deserialized to Date object"); + if ( + typeof req.body.historyWithoutRef[0].modificationDate !== 'string' + ) { + throw new Error('Should NOT be deserialized to Date object'); } req.body.id = new ObjectID(req.body.id); req.body.creationDateTime = new Date(req.body.creationDateTime); - req.body.history[0].modificationDate = new Date(req.body.history[0].modificationDate); - req.body.historyWithoutRef[0].modificationDate = new Date(req.body.historyWithoutRef[0].modificationDate); + req.body.history[0].modificationDate = new Date( + req.body.history[0].modificationDate, + ); + req.body.historyWithoutRef[0].modificationDate = new Date( + req.body.historyWithoutRef[0].modificationDate, + ); // We let creationDate et al as String and it should also work (either in Date Object ou String 'date' format) res.json(req.body); }); @@ -242,7 +259,7 @@ describe('699 serialize response components only', () => { }, false, ); - return app + return app; }); after(() => { @@ -256,9 +273,11 @@ describe('699 serialize response components only', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); - expect(r.body.history[0].modificationDate).to.equal("2020-12-20"); - expect(r.body.historyWithoutRef[0].modificationDate).to.equal("2020-12-20"); + expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); + expect(r.body.history[0].modificationDate).to.equal('2020-12-20'); + expect(r.body.historyWithoutRef[0].modificationDate).to.equal( + '2020-12-20', + ); })); it('should POST also works with deserialize on request then serialize en response', async () => @@ -274,8 +293,10 @@ describe('699 serialize response components only', () => { .set('Content-Type', 'application/json') .expect(200) .then((r) => { - expect(r.body.history[0].modificationDate).to.equal("2020-12-20"); - expect(r.body.historyWithoutRef[0].modificationDate).to.equal("2020-12-20"); + expect(r.body.history[0].modificationDate).to.equal('2020-12-20'); + expect(r.body.historyWithoutRef[0].modificationDate).to.equal( + '2020-12-20', + ); })); it('should POST throw error on invalid schema Date', async () => @@ -291,7 +312,9 @@ describe('699 serialize response components only', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/history/0/modificationDate must match format "date"'); + expect(r.body.message).to.equal( + 'request/body/history/0/modificationDate must match format "date"', + ); })); it('should POST throw error on invalid schema Date', async () => @@ -307,7 +330,9 @@ describe('699 serialize response components only', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/historyWithoutRef/0/modificationDate must match format "date"'); + expect(r.body.message).to.equal( + 'request/body/historyWithoutRef/0/modificationDate must match format "date"', + ); })); it('should throw error 500 on invalid object type instead of Date expected', async () => @@ -346,7 +371,4 @@ describe('699 serialize response components only', () => { })); */ - }); - - diff --git a/test/821.spec.ts b/test/821.spec.ts index 5b9bc75d..4e2fbbfc 100644 --- a/test/821.spec.ts +++ b/test/821.spec.ts @@ -7,24 +7,22 @@ import { startServer } from './common/app.common'; import { deepStrictEqual } from 'assert'; import * as path from 'path'; - const apiSpecPath = path.join('test', 'resources', '699.yaml'); -const date = new Date() +const date = new Date(); describe('issue #821 - serialization inside addiotionalProperties', () => { it('serializa both outer and inner date in addiotionalProperties', async () => { - const app = await createApp(apiSpecPath); - await request(app).get('/test').expect(200, - { + await request(app) + .get('/test') + .expect(200, { outer_date: date.toISOString(), other_info: { something: { - inner_date: date.toISOString() - } - } - } - ); + inner_date: date.toISOString(), + }, + }, + }); app.server!.close(); }); }); @@ -46,12 +44,11 @@ async function createApp( outer_date: date, other_info: { something: { - inner_date: date - } - } - }) - - }) + inner_date: date, + }, + }, + }); + }); app.use((err, req, res, next) => { console.error(err); // dump error to console for debug @@ -64,5 +61,3 @@ async function createApp( await startServer(app, 3001); return app; } - - diff --git a/test/ajv.resolves.more.than.one.schema.spec.ts b/test/ajv.resolves.more.than.one.schema.spec.ts index a61c6d7e..550520cc 100644 --- a/test/ajv.resolves.more.than.one.schema.spec.ts +++ b/test/ajv.resolves.more.than.one.schema.spec.ts @@ -12,15 +12,17 @@ describe('AJV: reference resolves to more than one schema', () => { const app = await createApp(apiSpec); - await request(app).get('/bear').expect(res => { - if (res.text.includes('resolves to more than one schema')) { - throw new Error('AJV not processing x-stoplight property correctly.') - } + await request(app) + .get('/bear') + .expect((res) => { + if (res.text.includes('resolves to more than one schema')) { + throw new Error('AJV not processing x-stoplight property correctly.'); + } - if (!res.text.includes('Black Bear')) { - throw new Error() - } - }) + if (!res.text.includes('Black Bear')) { + throw new Error(); + } + }); app.server.close(); @@ -46,8 +48,8 @@ async function createApp( ); app.use((err, req, res, next) => { - res.status(500).send(err.stack) - }) + res.status(500).send(err.stack); + }); await startServer(app, 3001); return app; @@ -65,15 +67,15 @@ function createApiSpec() { parameters: [], get: { responses: { - '200': { + '200': { description: 'OK', content: { 'application/json': { schema: { - $ref: '#/components/schemas/Bear' - } - } - } + $ref: '#/components/schemas/Bear', + }, + }, + }, }, }, }, @@ -84,15 +86,15 @@ function createApiSpec() { Bear: { title: 'Bear', 'x-stoplight': { - id: 'ug68n9uynqll0' + id: 'ug68n9uynqll0', }, properties: { type: { - type: 'string' - } - } - } - } - } + type: 'string', + }, + }, + }, + }, + }, }; } diff --git a/test/common/app.common.ts b/test/common/app.common.ts index 523948e8..355f23fd 100644 --- a/test/common/app.common.ts +++ b/test/common/app.common.ts @@ -17,22 +17,22 @@ export function routes(app) { const basePath = app.basePath; const router1 = express .Router() - .post('/', function(req: Request, res: Response): void { + .post('/', function (req: Request, res: Response): void { res.json({ name: `${req.method}: /router_1`, }); }) - .get('/', function(req: Request, res: Response): void { + .get('/', function (req: Request, res: Response): void { res.json({ name: `${req.method}: /router_1`, }); }) - .get('/:id', function(req: Request, res: Response): void { + .get('/:id', function (req: Request, res: Response): void { res.json({ name: `${req.method}: /router_1/${req.params.id}`, }); }) - .get('/:id/best/:bid', function(req: Request, res: Response): void { + .get('/:id/best/:bid', function (req: Request, res: Response): void { res.json({ name: `${req.method}: /router_1/${req.params.id}/best/${req.params.bid}`, }); @@ -40,7 +40,7 @@ export function routes(app) { app.use(`${basePath}/router_1`, router1); - app.get(`${basePath}/pets`, function(req: Request, res: Response): void { + app.get(`${basePath}/pets`, function (req: Request, res: Response): void { res.json({ test: 'hi', body: req.body, @@ -48,7 +48,7 @@ export function routes(app) { }); }); - app.post(`${basePath}/pets`, function(req: Request, res: Response): void { + app.post(`${basePath}/pets`, function (req: Request, res: Response): void { res.json({ body: req.body, query: req.query, @@ -56,48 +56,48 @@ export function routes(app) { }); }); - app.get(`${basePath}/pets/:id`, function(req: Request, res: Response): void { + app.get(`${basePath}/pets/:id`, function (req: Request, res: Response): void { res.json({ id: req.params.id, }); }); - app.get(`${basePath}/pets/:id/attributes`, function( - req: Request, - res: Response, - ): void { - res.json({ - id: req.params.id, - }); - }); + app.get( + `${basePath}/pets/:id/attributes`, + function (req: Request, res: Response): void { + res.json({ + id: req.params.id, + }); + }, + ); - app.get(`${basePath}/pets/:id/attributes/:attribute_id`, function( - req: Request, - res: Response, - ): void { - res.json({ - id: req.params.id, - attribute_id: req.params.attribute_id, - }); - }); + app.get( + `${basePath}/pets/:id/attributes/:attribute_id`, + function (req: Request, res: Response): void { + res.json({ + id: req.params.id, + attribute_id: req.params.attribute_id, + }); + }, + ); - app.post(`${basePath}/route_defined_in_express_not_openapi`, function( - req: Request, - res: Response, - ): void { - res.json({ - id: req.params.id, - }); - }); + app.post( + `${basePath}/route_defined_in_express_not_openapi`, + function (req: Request, res: Response): void { + res.json({ + id: req.params.id, + }); + }, + ); - app.get('/not_under_an_openapi_basepath', function( - req: Request, - res: Response, - ): void { - res.json({ - id: '/not_under_an_openapi_basepath', - }); - }); + app.get( + '/not_under_an_openapi_basepath', + function (req: Request, res: Response): void { + res.json({ + id: '/not_under_an_openapi_basepath', + }); + }, + ); // app.post('/v1/pets/:id/photos', function(req: Request, res: Response): void { // // req.file is the `avatar` file @@ -108,7 +108,7 @@ export function routes(app) { // metadata: req.body.metadata, // }); // }); - app.post('/v1/pets_charset', function(req: Request, res: Response): void { + app.post('/v1/pets_charset', function (req: Request, res: Response): void { // req.file is the `avatar` file // req.body will hold the text fields, if there were any res.json({ @@ -117,13 +117,16 @@ export function routes(app) { }); }); - app.post('/v1/pets_content_types', function(req: Request, res: Response): void { - // req.file is the `avatar` file - // req.body will hold the text fields, if there were any - res.json({ - ...req.body, - contentType: req.headers['content-type'], - id: 'new-id', - }); - }); + app.post( + '/v1/pets_content_types', + function (req: Request, res: Response): void { + // req.file is the `avatar` file + // req.body will hold the text fields, if there were any + res.json({ + ...req.body, + contentType: req.headers['content-type'], + id: 'new-id', + }); + }, + ); } diff --git a/test/common/app.ts b/test/common/app.ts index e9adf6e7..c7ade663 100644 --- a/test/common/app.ts +++ b/test/common/app.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import * as cookieParser from 'cookie-parser'; import * as logger from 'morgan'; -import * as OpenApiValidator from '../../src'; +import * as OpenApiValidator from '../../src'; import { startServer, routes } from './app.common'; import { OpenApiValidatorOpts } from '../../src/framework/types'; diff --git a/test/common/test.yaml b/test/common/test.yaml index 4d952dd9..d7ca5323 100644 --- a/test/common/test.yaml +++ b/test/common/test.yaml @@ -230,4 +230,4 @@ components: ApiKeyAuth: type: apiKey in: header - name: X-API-Key \ No newline at end of file + name: X-API-Key diff --git a/test/component.params.spec.ts b/test/component.params.spec.ts index 0a4c83ba..d0ffad4e 100644 --- a/test/component.params.spec.ts +++ b/test/component.params.spec.ts @@ -11,7 +11,7 @@ describe(packageJson.name, () => { before(async () => { // Set up the express app const apiSpec = path.join('test', 'resources', 'component.params.yaml'); - app = await createApp({ apiSpec }, 3005, app => + app = await createApp({ apiSpec }, 3005, (app) => app.use( `/`, express @@ -30,7 +30,7 @@ describe(packageJson.name, () => { request(app) .get(`/api/v1/meeting/${id}`) .expect(200) - .then(r => { + .then((r) => { expect(r.body.id).to.equal(id); }); }); diff --git a/test/content.type.spec.ts b/test/content.type.spec.ts index 9db4fbbf..9f55025e 100644 --- a/test/content.type.spec.ts +++ b/test/content.type.spec.ts @@ -38,10 +38,7 @@ describe('contentType', () => { }); it('should match media type if charset is specified in accepts, but charset not defined in schema', async () => { - const expectedTypes = [ - 'application/json', - 'application/xml', - ]; + const expectedTypes = ['application/json', 'application/xml']; const accepts = ['application/json; charset=utf-8']; const contentType = findResponseContent(accepts, expectedTypes); diff --git a/test/datetime.validation.spec.ts b/test/datetime.validation.spec.ts index 5538ec7b..685643d7 100644 --- a/test/datetime.validation.spec.ts +++ b/test/datetime.validation.spec.ts @@ -1,22 +1,22 @@ import * as path from 'path'; -import {expect} from 'chai'; +import { expect } from 'chai'; import * as request from 'supertest'; -import {createApp} from './common/app'; +import { createApp } from './common/app'; -describe("datetime.validation", () => { +describe('datetime.validation', () => { let app = null; - async function setupServer(validateFormats?: false | "full" | "fast") { + async function setupServer(validateFormats?: false | 'full' | 'fast') { // Set up the express app const apiSpec = path.join('test', 'resources', 'datetime.validation.yaml'); app = await createApp( { apiSpec, validateResponses: true, - validateFormats + validateFormats, }, 3005, - app => { + (app) => { // Define new coercion routes app.post(`${app.basePath}/date-time-validation`, (req, res) => { res.json(req.body); @@ -32,11 +32,10 @@ describe("datetime.validation", () => { afterEach(async () => { if (app) { - await new Promise(resolve => app.server.close(resolve)); + await new Promise((resolve) => app.server.close(resolve)); } }); - it('should return 200 if testDateTimeProperty is provided with invalid, but correctly formatted date time and default validation is enabled (past compatibility)', async () => { await setupServer(); await request(app) @@ -45,8 +44,8 @@ describe("datetime.validation", () => { testDateTimeProperty: '2000-13-03T12:13:14Z', }) .expect(200) - .then(r => { - const {body} = r; + .then((r) => { + const { body } = r; expect(body).to.have.property('testDateTimeProperty'); }); }); @@ -69,28 +68,28 @@ describe("datetime.validation", () => { testDateTimeProperty: 'blah-blah', }) .expect(200) - .then(r => { - const {body} = r; + .then((r) => { + const { body } = r; expect(body).to.have.property('testDateTimeProperty'); }); }); it('should return 200 if testDateTimeProperty is provided with valid date time and full validation enabled', async () => { - await setupServer("full"); + await setupServer('full'); await request(app) .post(`${app.basePath}/date-time-validation`) .send({ testDateTimeProperty: '2000-02-03T12:13:14Z', }) .expect(200) - .then(r => { - const {body} = r; + .then((r) => { + const { body } = r; expect(body).to.have.property('testDateTimeProperty'); }); }); it('should return 400 if testDateTimeProperty is provided with invalid date time and full validation enabled', async () => { - await setupServer("full"); + await setupServer('full'); await request(app) .post(`${app.basePath}/date-time-validation`) .send({ diff --git a/test/default-export.spec.ts b/test/default-export.spec.ts index cacff56d..ef60789c 100644 --- a/test/default-export.spec.ts +++ b/test/default-export.spec.ts @@ -13,8 +13,8 @@ const schema = { get: { operationId: 'anything', 'x-eov-operation-handler': 'controller-with-default', - responses: { 200: { description: 'home api' } } - } + responses: { 200: { description: 'home api' } }, + }, }, }, } as const; diff --git a/test/default.export.fn.spec.ts b/test/default.export.fn.spec.ts index e01a356e..52bc036a 100644 --- a/test/default.export.fn.spec.ts +++ b/test/default.export.fn.spec.ts @@ -3,7 +3,7 @@ import * as OpenApiValidator from '../src'; import { expect } from 'chai'; import * as request from 'supertest'; import * as path from 'path'; -import {OpenAPIV3} from "../src/framework/types"; +import { OpenAPIV3 } from '../src/framework/types'; describe('default export resolver', () => { let server = null; @@ -21,8 +21,8 @@ describe('default export resolver', () => { operationId: 'test#get', // @ts-ignore 'x-eov-operation-handler': 'routes/default-export-fn', - responses: { 200: { description: 'homepage' } } - } + responses: { 200: { description: 'homepage' } }, + }, }, }, }, @@ -41,7 +41,7 @@ describe('default export resolver', () => { .get(`/`) .expect(200) .then((r) => { - expect(r.body).to.have.property('message').that.equals("It Works!"); + expect(r.body).to.have.property('message').that.equals('It Works!'); }); }); }); diff --git a/test/escaped.characters.in.ref.path.spec.ts b/test/escaped.characters.in.ref.path.spec.ts index 2a2ec4e5..30c37d44 100644 --- a/test/escaped.characters.in.ref.path.spec.ts +++ b/test/escaped.characters.in.ref.path.spec.ts @@ -8,27 +8,35 @@ describe('when escaped characters are in path', () => { before(async () => { // Set up the express app - const apiSpec = path.join('test', 'resources', 'escaped.characters.in.path.yaml'); - app = await createApp({ apiSpec, $refParser: {mode: 'dereference'} }, 3005, app => { - app.use( - `${app.basePath}`, - express - .Router() - .post(`/auth/login`, (req, res) => res.json({ - 'token': 'SOME_JWT_TOKEN', - 'user': { - 'fullName': 'Eric Cartman', - 'role': 'admin', - }, - })), - ); - app.use( - `${app.basePath}`, - express - .Router() - .post(`/auth/register`, (req, res) => res.status(200).end()), - ); - }); + const apiSpec = path.join( + 'test', + 'resources', + 'escaped.characters.in.path.yaml', + ); + app = await createApp( + { apiSpec, $refParser: { mode: 'dereference' } }, + 3005, + (app) => { + app.use( + `${app.basePath}`, + express.Router().post(`/auth/login`, (req, res) => + res.json({ + token: 'SOME_JWT_TOKEN', + user: { + fullName: 'Eric Cartman', + role: 'admin', + }, + }), + ), + ); + app.use( + `${app.basePath}`, + express + .Router() + .post(`/auth/register`, (req, res) => res.status(200).end()), + ); + }, + ); }); after(() => { @@ -44,8 +52,7 @@ describe('when escaped characters are in path', () => { password: '123456', fullName: 'Eric Cartman', }) - .expect(200), - ); + .expect(200)); it('should be able to use an endpoint with some nested paths $ref 2', async () => request(app) @@ -54,7 +61,5 @@ describe('when escaped characters are in path', () => { email: 'jy95@perdu.com', password: '123456', }) - .expect(200), - ); - + .expect(200)); }); diff --git a/test/headers.2.spec.ts b/test/headers.2.spec.ts index d67c0afa..81f9b582 100644 --- a/test/headers.2.spec.ts +++ b/test/headers.2.spec.ts @@ -54,9 +54,7 @@ describe(packageJson.name, () => { .expect(400) .then((r) => { const e = r.body; - expect(e.message).to.contain( - 'must NOT have more than 255 characters', - ); + expect(e.message).to.contain('must NOT have more than 255 characters'); }); }); diff --git a/test/headers.spec.ts b/test/headers.spec.ts index 7c3ec860..79959ce6 100644 --- a/test/headers.spec.ts +++ b/test/headers.spec.ts @@ -71,7 +71,7 @@ describe(packageJson.name, () => { }) .expect(200)); - it('should succeed in sending a content-type: "application/json; version=1" in multiple ways', async () =>{ + it('should succeed in sending a content-type: "application/json; version=1" in multiple ways', async () => { await request(app) .post(`${app.basePath}/pets_content_types`) .set('Content-Type', 'application/json; version=1') @@ -82,7 +82,7 @@ describe(packageJson.name, () => { }) .expect(200) .expect((res) => { - expect(res.body.contentType).to.equal('application/json; version=1') + expect(res.body.contentType).to.equal('application/json; version=1'); }); await request(app) @@ -95,10 +95,10 @@ describe(packageJson.name, () => { }) .expect(200) .expect((res) => { - expect(res.body.contentType).to.equal('application/json;version=1') + expect(res.body.contentType).to.equal('application/json;version=1'); }); }); - + it('should throw a 415 error for unsupported "application/json; version=2" content type', async () => request(app) .post(`${app.basePath}/pets_content_types`) @@ -121,9 +121,9 @@ describe(packageJson.name, () => { }) .expect(200) .expect((res) => { - expect(res.body.contentType).to.equal('application/json;version=1') + expect(res.body.contentType).to.equal('application/json;version=1'); }); - + await request(app) .post(`${app.basePath}/pets_content_types`) .set('Content-Type', 'application/json; version=3') diff --git a/test/httperror.spec.ts b/test/httperror.spec.ts index 91ed8475..45b8872d 100644 --- a/test/httperror.spec.ts +++ b/test/httperror.spec.ts @@ -86,7 +86,9 @@ describe(packageJson.name, () => { path: '/method_not_allowed', message: 'POST method not allowed', }; - expect(new error.MethodNotAllowed(err)).to.be.an.instanceof(error.MethodNotAllowed); + expect(new error.MethodNotAllowed(err)).to.be.an.instanceof( + error.MethodNotAllowed, + ); expect( HttpError.create({ status: 405, diff --git a/test/ignore.paths.spec.ts b/test/ignore.paths.spec.ts index b795b7a3..6ff49924 100644 --- a/test/ignore.paths.spec.ts +++ b/test/ignore.paths.spec.ts @@ -12,7 +12,7 @@ describe('ignorePaths as RegExp', () => { app = await createApp( { apiSpec, ignorePaths: /.*\/hippies$/ }, 3005, - app => { + (app) => { app.all('/v1/hippies', (req, res) => { res.json([ { id: 1, name: 'farah' }, @@ -74,7 +74,7 @@ describe('ignorePaths as RegExp', () => { return request(app) .get(`${basePath}/pets/${id}`) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].path).contains('id'); expect(e[0].message).equals('must be integer'); @@ -85,7 +85,7 @@ describe('ignorePaths as RegExp', () => { request(app) .get(`${basePath}/route_defined_in_openapi_only`) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].message).to.equal("must have required property 'id'"); })); @@ -95,7 +95,7 @@ describe('ignorePaths as RegExp', () => { .get(`${basePath}/route_defined_in_openapi_only`) .query({ id: 123 }) .expect(404) - .then(r => { + .then((r) => { const e = r.body; // There is no route defined by express, hence the validator verifies parameters, // then it fails over to the express error handler. In this case returns empty @@ -114,7 +114,7 @@ describe('ignorePaths as Function', () => { app = await createApp( { apiSpec, ignorePaths: (path) => path.endsWith('/hippies') }, 3005, - app => { + (app) => { app.all('/v1/hippies', (req, res) => { res.json([ { id: 1, name: 'farah' }, @@ -173,7 +173,7 @@ describe('ignorePaths as Function', () => { return request(app) .get(`${basePath}/pets/${id}`) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].path).contains('id'); expect(e[0].message).equals('must be integer'); @@ -184,7 +184,7 @@ describe('ignorePaths as Function', () => { request(app) .get(`${basePath}/route_defined_in_openapi_only`) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].message).to.equal("must have required property 'id'"); })); @@ -194,7 +194,7 @@ describe('ignorePaths as Function', () => { .get(`${basePath}/route_defined_in_openapi_only`) .query({ id: 123 }) .expect(404) - .then(r => { + .then((r) => { const e = r.body; // There is no route defined by express, hence the validator verifies parameters, // then it fails over to the express error handler. In this case returns empty diff --git a/test/multi.spec.spec.ts b/test/multi.spec.spec.ts index 21f8d6ab..c93f9224 100644 --- a/test/multi.spec.spec.ts +++ b/test/multi.spec.spec.ts @@ -33,7 +33,7 @@ describe('multi-spec', () => { function createServer() { const express = require('express'); - const path = require('path'); + const path = require('path'); const http = require('http'); const OpenApiValidator = require('../src'); diff --git a/test/multipart.disabled.spec.ts b/test/multipart.disabled.spec.ts index 2b715fd6..45359836 100644 --- a/test/multipart.disabled.spec.ts +++ b/test/multipart.disabled.spec.ts @@ -39,10 +39,8 @@ describe(packageJson.name, () => { .set('Content-Type', 'multipart/form-data') .set('Accept', 'application/json') .expect(400) - .then(e => { - expect(e.body) - .has.property('errors') - .with.length(2); + .then((e) => { + expect(e.body).has.property('errors').with.length(2); expect(e.body.errors[0]) .has.property('message') .equal("must have required property 'file'"); @@ -93,10 +91,8 @@ describe(packageJson.name, () => { .set('Content-Type', 'application/json') .expect('Content-Type', /json/) .expect(415) - .then(r => { - expect(r.body) - .has.property('errors') - .with.length(1); + .then((r) => { + expect(r.body).has.property('errors').with.length(1); expect(r.body.errors[0]) .has.property('message') .equal('unsupported media type application/json'); @@ -111,7 +107,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('number'); diff --git a/test/multipart.spec.ts b/test/multipart.spec.ts index 807e3759..51352822 100644 --- a/test/multipart.spec.ts +++ b/test/multipart.spec.ts @@ -129,8 +129,8 @@ describe('a multipart request', () => { it('should validate multipart file and metadata', async () => { const array_with_objects = JSON.stringify([ { - foo: 'bar' - } + foo: 'bar', + }, ]); await request(app) @@ -169,16 +169,13 @@ describe('when request does not use parsers', () => { (app) => app.use( `${app.basePath}`, - express - .Router() - .post(`/sample_7`, (req, res) => res.json('ok')), + express.Router().post(`/sample_7`, (req, res) => res.json('ok')), ), false, false, ); }); - it('should validate that endpoint exists', async () => { await request(app) .post(`${app.basePath}/sample_7`) diff --git a/test/nested.routes.spec.ts b/test/nested.routes.spec.ts index 8bb8b81e..243d7a5b 100644 --- a/test/nested.routes.spec.ts +++ b/test/nested.routes.spec.ts @@ -10,31 +10,28 @@ describe(packageJson.name, () => { before(async () => { // Set up the express app - const apiSpec = path.join( - 'test', - 'resources', - 'nested.routes.yaml', - ); + const apiSpec = path.join('test', 'resources', 'nested.routes.yaml'); const apiRoute = express.Router(), nestedRoute = express.Router(); - app = await createApp({ - apiSpec, - validateRequests: true, - validateResponses: true, + app = await createApp( + { + apiSpec, + validateRequests: true, + validateResponses: true, }, 3005, - app =>{ + (app) => { app.use(`${app.basePath}`, apiRoute); apiRoute.use('/api-path', nestedRoute); nestedRoute.get('/pets', (_req, res) => { const json = [ { name: 'test', - tag: 'tag' - } + tag: 'tag', + }, ]; return res.json(json); - }) + }); }, true, ); @@ -51,6 +48,8 @@ describe(packageJson.name, () => { .expect(500) .then((r: any) => { const e = r.body; - expect(e.message).to.contain("/response/0 must have required property 'id'"); + expect(e.message).to.contain( + "/response/0 must have required property 'id'", + ); })); }); diff --git a/test/one.of.spec.ts b/test/one.of.spec.ts index 15c652d2..1a405a52 100644 --- a/test/one.of.spec.ts +++ b/test/one.of.spec.ts @@ -12,7 +12,7 @@ describe(packageJson.name, () => { app = await createApp( { apiSpec }, 3005, - app => { + (app) => { app.post(`${app.basePath}/one_of`, (req, res) => { res.json(req.body); }); @@ -80,11 +80,9 @@ describe(packageJson.name, () => { ], }) .expect(400) - .then(r => { + .then((r) => { const e = r.body; - expect(e.message).to.contain( - 'must match exactly one schema in oneOf', - ); + expect(e.message).to.contain('must match exactly one schema in oneOf'); }); }); @@ -136,11 +134,9 @@ describe(packageJson.name, () => { ], }) .expect(400) - .then(r => { + .then((r) => { const e = r.body; - expect(e.message).to.contain( - 'must match exactly one schema in oneOf', - ); + expect(e.message).to.contain('must match exactly one schema in oneOf'); }); }); }); diff --git a/test/oneof.readonly.yaml b/test/oneof.readonly.yaml index e2501405..6e1a49a0 100644 --- a/test/oneof.readonly.yaml +++ b/test/oneof.readonly.yaml @@ -2,7 +2,7 @@ openapi: 3.0.0 info: title: Dummy API description: Dummy API - version: "0.1.0" + version: '0.1.0' servers: - url: /v1 paths: @@ -10,54 +10,54 @@ paths: post: requestBody: content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/subE' - - $ref: '#/components/schemas/subF' - discriminator: - propertyName: type - mapping: - A: '#/components/schemas/subE' - B: '#/components/schemas/subF' + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/subE' + - $ref: '#/components/schemas/subF' + discriminator: + propertyName: type + mapping: + A: '#/components/schemas/subE' + B: '#/components/schemas/subF' responses: - 200: - description: successful operation + 200: + description: successful operation /any_of: post: requestBody: content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/subA' - - $ref: '#/components/schemas/subB' - discriminator: - propertyName: type - mapping: - A: '#/components/schemas/subA' - B: '#/components/schemas/subB' + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/subA' + - $ref: '#/components/schemas/subB' + discriminator: + propertyName: type + mapping: + A: '#/components/schemas/subA' + B: '#/components/schemas/subB' responses: - 200: - description: successful operation + 200: + description: successful operation /one_of: post: requestBody: content: - application/json: - schema: - oneOf: - - $ref: '#/components/schemas/subC' - - $ref: '#/components/schemas/subD' - discriminator: - propertyName: type - mapping: - C: '#/components/schemas/subC' - D: '#/components/schemas/subD' + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/subC' + - $ref: '#/components/schemas/subD' + discriminator: + propertyName: type + mapping: + C: '#/components/schemas/subC' + D: '#/components/schemas/subD' responses: - 200: - description: successful operation + 200: + description: successful operation components: schemas: @@ -69,10 +69,10 @@ components: type: string type: type: string - enum: [A, B] + enum: [A, B] required: - id - - type + - type one_required: type: object @@ -82,7 +82,7 @@ components: type: string type: type: string - enum: [A, B] + enum: [A, B] required: - id @@ -103,10 +103,10 @@ components: type: string type: type: string - enum: [C, D] + enum: [C, D] required: - id - - type + - type subD: allOf: @@ -117,10 +117,10 @@ components: type: string type: type: string - enum: [C, D] + enum: [C, D] required: - id - - type + - type subE: allOf: @@ -128,4 +128,4 @@ components: subF: allOf: - - $ref: '#/components/schemas/one_required' \ No newline at end of file + - $ref: '#/components/schemas/one_required' diff --git a/test/openapi.spec.ts b/test/openapi.spec.ts index 9726eb15..aa8190d1 100644 --- a/test/openapi.spec.ts +++ b/test/openapi.spec.ts @@ -38,11 +38,11 @@ describe(packageJson.name, () => { }); after(() => { - apps.forEach(app => app.server.close()); + apps.forEach((app) => app.server.close()); }); // [0,1] simulate range of 2 items - each item references an index in `apps` - [0, 1].forEach(i => { + [0, 1].forEach((i) => { describe(`GET ${basePath}/pets`, () => { it('should throw 400 on missing required query parameter', async () => request(apps[i]) @@ -50,7 +50,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e).to.have.length(2); expect(e[0].path).to.equal('/query/limit'); @@ -79,12 +79,12 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then(r => { + .then((r) => { expect(r.body.errors).to.deep.equal([ { path: '/query/unknown_param', - message: "Unknown query parameter 'unknown_param'" - } + message: "Unknown query parameter 'unknown_param'", + }, ]); })); @@ -98,7 +98,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('limit'); @@ -111,7 +111,7 @@ describe(packageJson.name, () => { .query(`limit=10&test=one&testJson={"foo": "bar"}`) .set('Accept', 'application/json') .expect('Content-Type', /json/) - .then(r => { + .then((r) => { expect(r.body) .to.have.property('message') .that.equals( @@ -142,7 +142,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('testJson'); @@ -155,10 +155,12 @@ describe(packageJson.name, () => { // query params default is style: form, explode: true - false, also comma separated list // testArrayNoExplode is set to form, explode false request(apps[i]) - .get(`${basePath}/pets?limit=10&test=one&testArrayNoExplode2=categoryId%3AIN%3A%5B1%2C2%2C3%2C4%2C5%5D,itemId%3AEQ%3A2`) + .get( + `${basePath}/pets?limit=10&test=one&testArrayNoExplode2=categoryId%3AIN%3A%5B1%2C2%2C3%2C4%2C5%5D,itemId%3AEQ%3A2`, + ) .set('Accept', 'application/json') .expect('Content-Type', /json/) - .expect(200)) + .expect(200)); it('should return 200 when comma separated array in query param', async () => // query params default is style: form, explode: true - false, also comma separated list @@ -182,7 +184,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then(r => { + .then((r) => { expect(r.body) .to.have.property('message') .that.equals( @@ -194,7 +196,9 @@ describe(packageJson.name, () => { request(apps[i]) .get(`${basePath}/pets`) .query( - `limit=10&test=one&testArrayNoExplode=${encodeURIComponent('foo,bar,baz')}`, + `limit=10&test=one&testArrayNoExplode=${encodeURIComponent( + 'foo,bar,baz', + )}`, ) .set('Accept', 'application/json') .expect('Content-Type', /json/) @@ -211,7 +215,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('testArrayNoExplode'); @@ -237,7 +241,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('testArrayExplode'); @@ -253,11 +257,9 @@ describe(packageJson.name, () => { .post(`${basePath}/pets`) .set('content-type', 'application/json') .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; - expect(e[0].message).to.equal( - "must have required property 'name'", - ); + expect(e[0].message).to.equal("must have required property 'name'"); })); it('should return 400 if required "name" property is missing', async () => @@ -265,11 +267,9 @@ describe(packageJson.name, () => { .post(`${basePath}/pets`) .send({}) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; - expect(e[0].message).to.equal( - "must have required property 'name'", - ); + expect(e[0].message).to.equal("must have required property 'name'"); })); it('should return 200 when post props are met', async () => @@ -279,7 +279,7 @@ describe(packageJson.name, () => { name: 'test', }) .expect(200) - .then(r => { + .then((r) => { expect(r.body.id).to.equal('new-id'); })); }); @@ -289,7 +289,7 @@ describe(packageJson.name, () => { request(apps[i]) .get('/not_under_an_openapi_basepath') .expect(200) - .then(r => { + .then((r) => { expect(r.body.id).to.equal('/not_under_an_openapi_basepath'); })); @@ -300,7 +300,7 @@ describe(packageJson.name, () => { request(apps[i]) .get(`${basePath}/route_not_defined_within_express`) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].message).to.equal( "must have required property 'name'", @@ -313,7 +313,7 @@ describe(packageJson.name, () => { .get(`${basePath}/route_not_defined_within_express`) .query({ name: 'test' }) .expect(404) - .then(r => { + .then((r) => { const e = r.body; // There is no route defined by express, hence the validator verifies parameters, // then it fails over to the express error handler. In this case returns empty @@ -325,7 +325,7 @@ describe(packageJson.name, () => { .get(`${basePath}/router_1/10`) .set('Accept', 'application/json') .expect(404) - .then(r => { + .then((r) => { const e = r.body.errors[0]; expect(e.message).to.equal('not found'); expect(e.path).to.equal(`${basePath}/router_1/10`); @@ -336,7 +336,7 @@ describe(packageJson.name, () => { .post(`${basePath}/route_not_defined_within_express`) .send() .expect(405) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].message).to.equal('POST method not allowed'); expect(e[0].path).to.equal( @@ -351,7 +351,7 @@ describe(packageJson.name, () => { name: 'test', }) .expect(404) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].message).to.equal('not found'); expect(e[0].path).to.equal(`${basePath}/unknown_route`); @@ -364,7 +364,7 @@ describe(packageJson.name, () => { name: 'test', }) .expect(404) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].message).to.equal('not found'); expect(e[0].path).to.equal( @@ -378,7 +378,7 @@ describe(packageJson.name, () => { .send('stuff') .set('content-type', 'application/xml') .expect(415) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].message).to.equal( 'unsupported media type application/xml', @@ -390,7 +390,7 @@ describe(packageJson.name, () => { .patch(`${basePath}/pets`) .send({ name: 'test' }) .expect(405) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].message).to.equal('PATCH method not allowed'); })); @@ -403,7 +403,7 @@ describe(packageJson.name, () => { return request(apps[i]) .get(`${basePath}/pets/${id}`) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].path).contains('id'); expect(e[0].message).equals('must be integer'); @@ -419,7 +419,7 @@ describe(packageJson.name, () => { testArrayNoExplode: ['unknown_value'], }) .expect(400) - .then(r => { + .then((r) => { const e = r.body.errors; expect(e[0].message).equals( 'must be equal to one of the allowed values: foo, bar, baz', @@ -433,7 +433,7 @@ describe(packageJson.name, () => { return request(apps[i]) .get(`${basePath}/pets/${id}/attributes/${attributeId}`) .expect(200) - .then(r => { + .then((r) => { expect(r.body.id).equals(Number.parseInt(id)); expect(r.body.attribute_id).equals(Number.parseInt(attributeId)); }); @@ -444,7 +444,7 @@ describe(packageJson.name, () => { return request(apps[i]) .get(`${basePath}/pets/${id}`) .expect(200) - .then(r => { + .then((r) => { expect(r.body.id).equals(id); }); }); diff --git a/test/openapi_3.1/components.spec.ts b/test/openapi_3.1/components.spec.ts index 958c81bb..d4ddd28d 100644 --- a/test/openapi_3.1/components.spec.ts +++ b/test/openapi_3.1/components.spec.ts @@ -1,6 +1,6 @@ import * as request from 'supertest'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('components support - OpenAPI 3.1', () => { let app; @@ -22,9 +22,6 @@ describe('components support - OpenAPI 3.1', () => { it('should support an API that only has components defined, but provides no routes', () => { // The component is not made available by the provider API, so the request will return 404 // This test ensures that the request flow happens normally without any interruptions due to being a component - return request(app) - .get(`${app.basePath}/components`) - .expect(404); + return request(app).get(`${app.basePath}/components`).expect(404); }); - -}) \ No newline at end of file +}); diff --git a/test/openapi_3.1/components_path_items.spec.ts b/test/openapi_3.1/components_path_items.spec.ts index cbd282da..bf0957e6 100644 --- a/test/openapi_3.1/components_path_items.spec.ts +++ b/test/openapi_3.1/components_path_items.spec.ts @@ -1,23 +1,27 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('component path item support - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join('test', 'openapi_3.1', 'resources', 'components_path_items.yaml'); + const apiSpec = join( + 'test', + 'openapi_3.1', + 'resources', + 'components_path_items.yaml', + ); app = await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, - (app) => app.use( - express - .Router() - .get(`/v1/entity`, (req, res) => - res.status(200).json({}), - ), - ) + (app) => + app.use( + express + .Router() + .get(`/v1/entity`, (req, res) => res.status(200).json({})), + ), ); }); @@ -26,9 +30,6 @@ describe('component path item support - OpenAPI 3.1', () => { }); it('should support path item on components', async () => { - return request(app) - .get(`${app.basePath}/entity`) - .expect(200); + return request(app).get(`${app.basePath}/entity`).expect(200); }); - -}) \ No newline at end of file +}); diff --git a/test/openapi_3.1/info_summary.spec.ts b/test/openapi_3.1/info_summary.spec.ts index 20e8c5dc..b1144ea1 100644 --- a/test/openapi_3.1/info_summary.spec.ts +++ b/test/openapi_3.1/info_summary.spec.ts @@ -1,12 +1,17 @@ import * as request from 'supertest'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('summary support - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join('test', 'openapi_3.1', 'resources', 'info_summary.yaml'); + const apiSpec = join( + 'test', + 'openapi_3.1', + 'resources', + 'info_summary.yaml', + ); app = await createApp( { apiSpec, validateRequests: true }, 3005, @@ -22,9 +27,6 @@ describe('summary support - OpenAPI 3.1', () => { it('should support an API that has an info with a summary defined', () => { // The endpoint is not made available by the provider API, so the request will return 404 // This test ensures that the request flow happens normally without any interruptions - return request(app) - .get(`${app.basePath}/webhook`) - .expect(404); + return request(app).get(`${app.basePath}/webhook`).expect(404); }); - -}) \ No newline at end of file +}); diff --git a/test/openapi_3.1/license_identifier.spec.ts b/test/openapi_3.1/license_identifier.spec.ts index 7f615a93..10f307c1 100644 --- a/test/openapi_3.1/license_identifier.spec.ts +++ b/test/openapi_3.1/license_identifier.spec.ts @@ -1,12 +1,17 @@ import * as request from 'supertest'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('identifier support - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join('test', 'openapi_3.1', 'resources', 'license_identifier.yaml'); + const apiSpec = join( + 'test', + 'openapi_3.1', + 'resources', + 'license_identifier.yaml', + ); app = await createApp( { apiSpec, validateRequests: true }, 3005, @@ -22,9 +27,6 @@ describe('identifier support - OpenAPI 3.1', () => { it('should support an API that has an info with a summary defined', () => { // The endpoint is not made available by the provider API, so the request will return 404 // This test ensures that the request flow happens normally without any interruptions - return request(app) - .get(`${app.basePath}/webhook`) - .expect(404); + return request(app).get(`${app.basePath}/webhook`).expect(404); }); - -}) \ No newline at end of file +}); diff --git a/test/openapi_3.1/non_defined_semantics_request_body.spec.ts b/test/openapi_3.1/non_defined_semantics_request_body.spec.ts index e843a587..032b3ba7 100644 --- a/test/openapi_3.1/non_defined_semantics_request_body.spec.ts +++ b/test/openapi_3.1/non_defined_semantics_request_body.spec.ts @@ -1,25 +1,29 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('Request body in operations without well defined semantics - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join('test', 'openapi_3.1', 'resources', 'non_defined_semantics_request_body.yaml'); + const apiSpec = join( + 'test', + 'openapi_3.1', + 'resources', + 'non_defined_semantics_request_body.yaml', + ); app = await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, - (app) => app.use( - express - .Router() - .get(`/v1/entity`, (req, res) => + (app) => + app.use( + express.Router().get(`/v1/entity`, (req, res) => res.status(200).json({ - property: null + property: null, }), ), - ) + ), ); }); @@ -33,7 +37,7 @@ describe('Request body in operations without well defined semantics - OpenAPI 3. return request(app) .get(`${app.basePath}/entity`) .set('Content-Type', 'application/json') - .send({request: 123}) + .send({ request: 123 }) .expect(400); }); @@ -42,7 +46,7 @@ describe('Request body in operations without well defined semantics - OpenAPI 3. return request(app) .delete(`${app.basePath}/entity`) .set('Content-Type', 'application/json') - .send({request: 123}) + .send({ request: 123 }) .expect(400); }); -}) \ No newline at end of file +}); diff --git a/test/openapi_3.1/path_no_response.spec.ts b/test/openapi_3.1/path_no_response.spec.ts index b40619e3..6c7611dd 100644 --- a/test/openapi_3.1/path_no_response.spec.ts +++ b/test/openapi_3.1/path_no_response.spec.ts @@ -1,25 +1,27 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('operation object without response - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join('test', 'openapi_3.1', 'resources', 'path_no_response.yaml'); + const apiSpec = join( + 'test', + 'openapi_3.1', + 'resources', + 'path_no_response.yaml', + ); app = await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, - (app) => app.use( - express - .Router() - .get(`/v1`, (req, res) => - res.status(200).end(), - ), - ) + (app) => + app.use( + express.Router().get(`/v1`, (req, res) => res.status(200).end()), + ), ); - app + app; }); after(() => { @@ -28,9 +30,6 @@ describe('operation object without response - OpenAPI 3.1', () => { // In OpenAPI 3.1 it's possible to have a path without a response defined it('should support endpoint with defined operation object without response', () => { - return request(app) - .get(`${app.basePath}`) - .expect(200); + return request(app).get(`${app.basePath}`).expect(200); }); - -}) \ No newline at end of file +}); diff --git a/test/openapi_3.1/resources/components.yaml b/test/openapi_3.1/resources/components.yaml index b968adec..d70fd47c 100644 --- a/test/openapi_3.1/resources/components.yaml +++ b/test/openapi_3.1/resources/components.yaml @@ -3,4 +3,4 @@ openapi: 3.1.0 info: title: API version: 1.0.0 -components: {} \ No newline at end of file +components: {} diff --git a/test/openapi_3.1/resources/components_path_items.yaml b/test/openapi_3.1/resources/components_path_items.yaml index 030e6757..df7579e4 100644 --- a/test/openapi_3.1/resources/components_path_items.yaml +++ b/test/openapi_3.1/resources/components_path_items.yaml @@ -1,21 +1,21 @@ openapi: 3.1.0 info: title: Example specification - version: "1.0" + version: '1.0' servers: - url: /v1 components: - pathItems: + pathItems: entity: - get: + get: description: 'test' - responses: + responses: 200: description: GETS my entity content: application/json: schema: - type: object + type: object paths: /entity: $ref: '#/components/pathItems/entity' diff --git a/test/openapi_3.1/resources/info_summary.yaml b/test/openapi_3.1/resources/info_summary.yaml index 27e120cd..079bd435 100644 --- a/test/openapi_3.1/resources/info_summary.yaml +++ b/test/openapi_3.1/resources/info_summary.yaml @@ -4,4 +4,4 @@ info: title: API summary: My lovely API version: 1.0.0 -components: {} \ No newline at end of file +components: {} diff --git a/test/openapi_3.1/resources/license_identifier.yaml b/test/openapi_3.1/resources/license_identifier.yaml index 85dd47a1..9530f345 100644 --- a/test/openapi_3.1/resources/license_identifier.yaml +++ b/test/openapi_3.1/resources/license_identifier.yaml @@ -7,4 +7,4 @@ info: license: name: Apache identifier: Apache-2.0 -components: {} \ No newline at end of file +components: {} diff --git a/test/openapi_3.1/resources/non_defined_semantics_request_body.yaml b/test/openapi_3.1/resources/non_defined_semantics_request_body.yaml index 5114a27a..ef411185 100644 --- a/test/openapi_3.1/resources/non_defined_semantics_request_body.yaml +++ b/test/openapi_3.1/resources/non_defined_semantics_request_body.yaml @@ -26,7 +26,7 @@ paths: '200': description: OK content: - application/json: + application/json: schema: title: Entity type: object @@ -46,10 +46,10 @@ paths: '200': description: OK content: - application/json: + application/json: schema: title: Entity type: object properties: property: - type: ['string', 'null'] \ No newline at end of file + type: ['string', 'null'] diff --git a/test/openapi_3.1/resources/path_no_response.yaml b/test/openapi_3.1/resources/path_no_response.yaml index 5426037b..8b36f052 100644 --- a/test/openapi_3.1/resources/path_no_response.yaml +++ b/test/openapi_3.1/resources/path_no_response.yaml @@ -8,4 +8,4 @@ servers: - url: /v1 paths: /: - get: {} \ No newline at end of file + get: {} diff --git a/test/openapi_3.1/resources/server_variable_no_default.yaml b/test/openapi_3.1/resources/server_variable_no_default.yaml index 8408bf44..c39cab8a 100644 --- a/test/openapi_3.1/resources/server_variable_no_default.yaml +++ b/test/openapi_3.1/resources/server_variable_no_default.yaml @@ -9,5 +9,4 @@ servers: variables: var: enum: ['a', 'b'] -components: - {} \ No newline at end of file +components: {} diff --git a/test/openapi_3.1/resources/type_null.yaml b/test/openapi_3.1/resources/type_null.yaml index 54d885f6..20a8020b 100644 --- a/test/openapi_3.1/resources/type_null.yaml +++ b/test/openapi_3.1/resources/type_null.yaml @@ -7,17 +7,16 @@ servers: paths: /entity: get: - summary: test - description: GETS my entity - responses: - '200': - description: OK - content: - application/json: - schema: - title: Entity - type: object - properties: - property: - type: ['string', 'null'] - \ No newline at end of file + summary: test + description: GETS my entity + responses: + '200': + description: OK + content: + application/json: + schema: + title: Entity + type: object + properties: + property: + type: ['string', 'null'] diff --git a/test/openapi_3.1/resources/unevaluated_properties.yaml b/test/openapi_3.1/resources/unevaluated_properties.yaml index cc40845a..b5445333 100644 --- a/test/openapi_3.1/resources/unevaluated_properties.yaml +++ b/test/openapi_3.1/resources/unevaluated_properties.yaml @@ -25,4 +25,4 @@ paths: $ref: '#/components/schemas/EntityRequest' responses: '204': - description: No Content \ No newline at end of file + description: No Content diff --git a/test/openapi_3.1/resources/webhook.yaml b/test/openapi_3.1/resources/webhook.yaml index 27bbd8e2..941aaa57 100644 --- a/test/openapi_3.1/resources/webhook.yaml +++ b/test/openapi_3.1/resources/webhook.yaml @@ -14,9 +14,9 @@ webhooks: content: application/json: schema: - $ref: "#/components/schemas/Pet" + $ref: '#/components/schemas/Pet' responses: - "200": + '200': description: Return a 200 status to indicate that the data was received successfully components: @@ -32,4 +32,4 @@ components: name: type: string tag: - type: string \ No newline at end of file + type: string diff --git a/test/openapi_3.1/server_variable.spec.ts b/test/openapi_3.1/server_variable.spec.ts index d790b9c6..c028898a 100644 --- a/test/openapi_3.1/server_variable.spec.ts +++ b/test/openapi_3.1/server_variable.spec.ts @@ -1,21 +1,24 @@ import * as request from 'supertest'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('server variable - OpenAPI 3.1', () => { it('returns 500 when server variable has no default property', async () => { - const apiSpec = join('test', 'openapi_3.1', 'resources', 'server_variable_no_default.yaml'); - const app = await createApp( + const apiSpec = join( + 'test', + 'openapi_3.1', + 'resources', + 'server_variable_no_default.yaml', + ); + const app = (await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, undefined, false, - ) as any; + )) as any; - await request(app) - .get(`${app.basePath}`) - .expect(500); + await request(app).get(`${app.basePath}`).expect(500); app.server.close(); }); -}) \ No newline at end of file +}); diff --git a/test/openapi_3.1/type_null.spec.ts b/test/openapi_3.1/type_null.spec.ts index 452626c2..b9b69bc3 100644 --- a/test/openapi_3.1/type_null.spec.ts +++ b/test/openapi_3.1/type_null.spec.ts @@ -1,7 +1,7 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('type null support - OpenAPI 3.1', () => { let app; @@ -11,15 +11,14 @@ describe('type null support - OpenAPI 3.1', () => { app = await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, - (app) => app.use( - express - .Router() - .get(`/v1/entity`, (req, res) => + (app) => + app.use( + express.Router().get(`/v1/entity`, (req, res) => res.status(200).json({ - property: null + property: null, }), ), - ) + ), ); }); @@ -29,9 +28,6 @@ describe('type null support - OpenAPI 3.1', () => { // In OpenAPI 3.1, nullable = true was replaced by types = [..., null]. This test ensure that it works with Express OpenAPI Validator it('should support an API with types set to null', async () => { - return request(app) - .get(`${app.basePath}/entity`) - .expect(200); + return request(app).get(`${app.basePath}/entity`).expect(200); }); - -}) \ No newline at end of file +}); diff --git a/test/openapi_3.1/unevaluated_properties.spec.ts b/test/openapi_3.1/unevaluated_properties.spec.ts index edb84535..df6f0793 100644 --- a/test/openapi_3.1/unevaluated_properties.spec.ts +++ b/test/openapi_3.1/unevaluated_properties.spec.ts @@ -1,23 +1,24 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('Unevaluated Properties in requests', () => { let app; before(async () => { - const apiSpec = join('test', 'openapi_3.1', 'resources', 'unevaluated_properties.yaml'); - app = await createApp( - { apiSpec, validateRequests: true }, - 3005, - (app) => app.use( + const apiSpec = join( + 'test', + 'openapi_3.1', + 'resources', + 'unevaluated_properties.yaml', + ); + app = await createApp({ apiSpec, validateRequests: true }, 3005, (app) => + app.use( express .Router() - .post(`/v1/entity`, (_req, res) => - res.status(204).json(), - ), - ) + .post(`/v1/entity`, (_req, res) => res.status(204).json()), + ), ); }); @@ -25,12 +26,11 @@ describe('Unevaluated Properties in requests', () => { app.server.close(); }); - it('should reject request body with unevaluated properties', async () => { return request(app) .post(`${app.basePath}/entity`) .set('Content-Type', 'application/json') - .send({request: '123', additionalProperty: '321'}) + .send({ request: '123', additionalProperty: '321' }) .expect(400); }); @@ -38,8 +38,7 @@ describe('Unevaluated Properties in requests', () => { return request(app) .post(`${app.basePath}/entity`) .set('Content-Type', 'application/json') - .send({request: '123' }) + .send({ request: '123' }) .expect(204); }); - -}) \ No newline at end of file +}); diff --git a/test/openapi_3.1/webhook.spec.ts b/test/openapi_3.1/webhook.spec.ts index 58e81b1d..3e840502 100644 --- a/test/openapi_3.1/webhook.spec.ts +++ b/test/openapi_3.1/webhook.spec.ts @@ -1,6 +1,6 @@ import * as request from 'supertest'; -import { createApp } from "../common/app"; -import { join } from "path"; +import { createApp } from '../common/app'; +import { join } from 'path'; describe('webhook support - OpenAPI 3.1', () => { let app; @@ -22,9 +22,6 @@ describe('webhook support - OpenAPI 3.1', () => { it('should support an API that only has webhooks defined, but provides no routes', () => { // The webhook is not made available by the provider API, so the request will return 404 // This test ensures that the request flow happens normally without any interruptions due to being a webhook - return request(app) - .get(`${app.basePath}/webhook`) - .expect(404); + return request(app).get(`${app.basePath}/webhook`).expect(404); }); - -}) \ No newline at end of file +}); diff --git a/test/optional-request-body.spec.ts b/test/optional-request-body.spec.ts index f99aa8d6..ad49fa5b 100644 --- a/test/optional-request-body.spec.ts +++ b/test/optional-request-body.spec.ts @@ -33,9 +33,7 @@ describe(packageJson.name, () => { .expect(201)); it('create document should return 201 with empty body', async () => - request(app) - .post(`/documents`) - .expect(201)); + request(app).post(`/documents`).expect(201)); it('return 415', async () => request(app) diff --git a/test/path.level.parameters.spec.ts b/test/path.level.parameters.spec.ts index 7f61a476..ac3447a2 100644 --- a/test/path.level.parameters.spec.ts +++ b/test/path.level.parameters.spec.ts @@ -42,7 +42,7 @@ describe(packageJson.name, () => { .get(`${app.basePath}/path_level_parameters?operationLevel=123`) .send() .expect(400) - .then(r => { + .then((r) => { expect(r.body.errors).to.be.an('array'); expect(r.body.errors).to.have.length(1); const message = r.body.errors[0].message; @@ -54,7 +54,7 @@ describe(packageJson.name, () => { .get(`${app.basePath}/path_level_parameters?pathLevel=123`) .send() .expect(400) - .then(r => { + .then((r) => { expect(r.body.errors).to.be.an('array'); expect(r.body.errors).to.have.length(1); const message = r.body.errors[0].message; @@ -68,10 +68,10 @@ describe(packageJson.name, () => { .get(`${app.basePath}/path_level_parameters`) .send() .expect(400) - .then(r => { + .then((r) => { expect(r.body.errors).to.be.an('array'); expect(r.body.errors).to.have.length(2); - const messages = r.body.errors.map(err => err.message); + const messages = r.body.errors.map((err) => err.message); expect(messages).to.have.members([ "must have required property 'pathLevel'", "must have required property 'operationLevel'", @@ -80,7 +80,9 @@ describe(packageJson.name, () => { it('should return 200 if both pathLevel and operationLevel query parameter are provided', async () => request(app) - .get(`${app.basePath}/path_level_parameters?operationLevel=123&pathLevel=123`) + .get( + `${app.basePath}/path_level_parameters?operationLevel=123&pathLevel=123`, + ) .send() .expect(200)); }); diff --git a/test/paths.sort.spec.ts b/test/paths.sort.spec.ts index 6d2fc4fa..1adfaad7 100644 --- a/test/paths.sort.spec.ts +++ b/test/paths.sort.spec.ts @@ -1,6 +1,4 @@ -import { - sortRoutes, -} from '../src/framework/openapi.spec.loader'; +import { sortRoutes } from '../src/framework/openapi.spec.loader'; import { expect } from 'chai'; describe('url sorter', () => { @@ -38,7 +36,7 @@ describe('url sorter', () => { }); function asRouteMetadatas(urls: string[]) { - return urls.map(u => ({ + return urls.map((u) => ({ expressRoute: u, })); } diff --git a/test/query.params.allow.unknown.spec.ts b/test/query.params.allow.unknown.spec.ts index 22b360fa..cd43cd4c 100644 --- a/test/query.params.allow.unknown.spec.ts +++ b/test/query.params.allow.unknown.spec.ts @@ -15,7 +15,7 @@ describe(packageJson.name, () => { app = await createApp( { apiSpec, validateRequests: { allowUnknownQueryParameters: true } }, 3005, - app => + (app) => app.use( `${app.basePath}`, express @@ -62,7 +62,7 @@ describe(packageJson.name, () => { unknown_prop: 'test', }) .expect(400) - .then(r => { + .then((r) => { expect(r.body.errors).to.be.an('array'); })); }); diff --git a/test/query.params.spec.ts b/test/query.params.spec.ts index 536f0034..9a546f27 100644 --- a/test/query.params.spec.ts +++ b/test/query.params.spec.ts @@ -11,7 +11,7 @@ describe(packageJson.name, () => { before(async () => { // Set up the express app const apiSpec = path.join('test', 'resources', 'query.params.yaml'); - app = await createApp({ apiSpec }, 3005, app => + app = await createApp({ apiSpec }, 3005, (app) => app.use( `${app.basePath}`, express @@ -50,7 +50,7 @@ describe(packageJson.name, () => { name: 'max', }) .expect(400) - .then(r => { + .then((r) => { expect(r.body.errors).to.be.an('array'); })); @@ -58,7 +58,7 @@ describe(packageJson.name, () => { request(app) .get(`${app.basePath}/no_query_params`) .expect(200) - .then(r => { + .then((r) => { expect(r.body.complete).to.equal(true); })); @@ -74,7 +74,7 @@ describe(packageJson.name, () => { unknown_prop: 'test', }) .expect(400) - .then(r => { + .then((r) => { expect(r.body.errors).to.be.an('array'); })); @@ -98,13 +98,11 @@ describe(packageJson.name, () => { owner_name: 'carmine', }) .expect(400) - .then(r => { + .then((r) => { expect(r.body) .to.have.property('message') .that.equals("Empty value found for query parameter 'breed'"); - expect(r.body.errors) - .to.be.an('array') - .with.length(1); + expect(r.body.errors).to.be.an('array').with.length(1); expect(r.body.errors[0].path).to.equal('/query/breed'); })); @@ -131,7 +129,7 @@ describe(packageJson.name, () => { request(app) .get(`${app.basePath}/no_reserved?value=ThisHas$ReservedChars!`) .expect(400) - .then(r => { + .then((r) => { const body = r.body; expect(body.message).equals( "Parameter 'value' must be url encoded. Its value may not contain reserved characters.", diff --git a/test/query.serialization.ts b/test/query.serialization.ts index 019e55ab..4070714d 100644 --- a/test/query.serialization.ts +++ b/test/query.serialization.ts @@ -13,8 +13,12 @@ describe('styles', () => { `/`, express .Router() - .get('/api/q_form_explode', (req, res) => res.json({ query: req.query })) - .get('/api/q_form_nexplode', (req, res) => res.json({ query: req.query })), + .get('/api/q_form_explode', (req, res) => + res.json({ query: req.query }), + ) + .get('/api/q_form_nexplode', (req, res) => + res.json({ query: req.query }), + ), ), ); }); diff --git a/test/read.only.removeadditional.spec.ts b/test/read.only.removeadditional.spec.ts index 2f065c04..cad46ce9 100644 --- a/test/read.only.removeadditional.spec.ts +++ b/test/read.only.removeadditional.spec.ts @@ -10,51 +10,58 @@ describe(packageJson.name, () => { before(async () => { // Set up the express app const apiSpec = path.join('test', 'resources', 'read.only.yaml'); - app = await createApp({ apiSpec, validateRequests: {removeAdditional:true}, validateResponses: true }, 3005, (app) => - app - .post(`${app.basePath}/products`, (req, res) => res.json(req.body)) - .get(`${app.basePath}/products`, (req, res) => - res.json([ - { - id: 'id_1', - name: 'name_1', - price: 9.99, - created_at: new Date().toISOString(), - }, - ]), - ) - .post(`${app.basePath}/products/inlined`, (req, res) => - res.json(req.body), - ) - .post(`${app.basePath}/user`, (req, res) => - res.json({ - ...req.body, - ...(req.query.include_id ? { id: 'test_id' } : {}), - }), - ) - .post(`${app.basePath}/user_inlined`, (req, res) => - res.json({ - ...req.body, - ...(req.query.include_id ? { id: 'test_id' } : {}), + app = await createApp( + { + apiSpec, + validateRequests: { removeAdditional: true }, + validateResponses: true, + }, + 3005, + (app) => + app + .post(`${app.basePath}/products`, (req, res) => res.json(req.body)) + .get(`${app.basePath}/products`, (req, res) => + res.json([ + { + id: 'id_1', + name: 'name_1', + price: 9.99, + created_at: new Date().toISOString(), + }, + ]), + ) + .post(`${app.basePath}/products/inlined`, (req, res) => + res.json(req.body), + ) + .post(`${app.basePath}/user`, (req, res) => + res.json({ + ...req.body, + ...(req.query.include_id ? { id: 'test_id' } : {}), + }), + ) + .post(`${app.basePath}/user_inlined`, (req, res) => + res.json({ + ...req.body, + ...(req.query.include_id ? { id: 'test_id' } : {}), + }), + ) + .post(`${app.basePath}/products/nested`, (req, res) => { + const body = req.body; + body.id = 'test'; + body.created_at = new Date().toISOString(); + body.reviews = body.reviews.map((r) => ({ + id: 99, + rating: r.rating ?? 2, + })); + res.json(body); + }) + .post(`${app.basePath}/readonly_required_allof`, (req, res) => { + const json = { + name: 'My Name', + ...(req.query.include_id ? { id: 'test_id' } : {}), + }; + res.json(json); }), - ) - .post(`${app.basePath}/products/nested`, (req, res) => { - const body = req.body; - body.id = 'test'; - body.created_at = new Date().toISOString(); - body.reviews = body.reviews.map((r) => ({ - id: 99, - rating: r.rating ?? 2, - })); - res.json(body); - }) - .post(`${app.basePath}/readonly_required_allof`, (req, res) => { - const json = { - name: 'My Name', - ...(req.query.include_id ? { id: 'test_id' } : {}), - }; - res.json(json); - }), ); }); @@ -63,23 +70,22 @@ describe(packageJson.name, () => { }); it('should remove read only properties in requests thanks to removeAdditional', async () => - request(app) - .post(`${app.basePath}/products`) - .set('content-type', 'application/json') - .send({ - id: 'id_1', - name: 'some name', - price: 10.99, - created_at: new Date().toISOString(), - }) - .expect(200) - .then((r) => { - const body = r.body; - // id is a readonly property and should not be allowed in the request - // but, as removeAdditional is true for requests, it should be deleted before entering in the route - expect(body.id).to.be.undefined; - })); - + request(app) + .post(`${app.basePath}/products`) + .set('content-type', 'application/json') + .send({ + id: 'id_1', + name: 'some name', + price: 10.99, + created_at: new Date().toISOString(), + }) + .expect(200) + .then((r) => { + const body = r.body; + // id is a readonly property and should not be allowed in the request + // but, as removeAdditional is true for requests, it should be deleted before entering in the route + expect(body.id).to.be.undefined; + })); it('should allow read only properties in responses', async () => request(app) @@ -102,12 +108,11 @@ describe(packageJson.name, () => { .expect(200) .then((r) => { const body = r.body; - // id is a readonly property and should not not be allowed in the request - // but, as removeAdditional is true for requests, it should be deleted before entering in the route - expect(body.id).to.be.undefined; + // id is a readonly property and should not not be allowed in the request + // but, as removeAdditional is true for requests, it should be deleted before entering in the route + expect(body.id).to.be.undefined; })); - it('should remove read only properties in requests (nested and deep nested schema $refs) thanks to removeAdditional', async () => request(app) .post(`${app.basePath}/products/nested`) @@ -117,18 +122,20 @@ describe(packageJson.name, () => { name: 'some name', price: 10.99, created_at: new Date().toISOString(), - reviews: [{ - id: 10, - rating: 5, - }], + reviews: [ + { + id: 10, + rating: 5, + }, + ], }) .expect(200) .then((r) => { const body = r.body; - // id is a readonly property and should not not be allowed in the request - // but, as removeAdditional is true for requests, it should be deleted before entering in the route - expect(body.id).to.be.equal('test'); - expect(body.reviews[0].id).to.be.equal(99); + // id is a readonly property and should not not be allowed in the request + // but, as removeAdditional is true for requests, it should be deleted before entering in the route + expect(body.id).to.be.equal('test'); + expect(body.reviews[0].id).to.be.equal(99); })); it('should pass validation if required read only properties to be missing from request ($ref)', async () => diff --git a/test/read.only.spec.ts b/test/read.only.spec.ts index da4ffc0e..66d62535 100644 --- a/test/read.only.spec.ts +++ b/test/read.only.spec.ts @@ -113,10 +113,12 @@ describe(packageJson.name, () => { name: 'some name', price: 10.99, created_at: new Date().toISOString(), - reviews: [{ - id: 'review_id', - rating: 5, - }], + reviews: [ + { + id: 'review_id', + rating: 5, + }, + ], }) .expect(400) .then((r) => { diff --git a/test/request.bodies.ref.spec.ts b/test/request.bodies.ref.spec.ts index 0a263c55..d738c756 100644 --- a/test/request.bodies.ref.spec.ts +++ b/test/request.bodies.ref.spec.ts @@ -125,9 +125,7 @@ describe('request bodies', () => { expect(r.body.errors).to.be.an('array'); expect(r.body.errors).to.have.length(1); const message = r.body.errors[0].message; - expect(message).to.equal( - "must have required property 'testProperty'", - ); + expect(message).to.equal("must have required property 'testProperty'"); })); it('should return 200 if testProperty body property is provided', async () => diff --git a/test/resources/699.yaml b/test/resources/699.yaml index 0126109f..2107f2f8 100644 --- a/test/resources/699.yaml +++ b/test/resources/699.yaml @@ -1,7 +1,7 @@ -openapi: "3.0.0" +openapi: '3.0.0' info: - title: "Test for allOf" - version: "1" + title: 'Test for allOf' + version: '1' servers: - url: /v1/ paths: @@ -12,7 +12,7 @@ paths: in: path required: true schema: - $ref: "#/components/schemas/ObjectId" + $ref: '#/components/schemas/ObjectId' - name: baddateresponse in: query schema: @@ -26,28 +26,28 @@ paths: in: query required: false schema: - $ref: "#/components/schemas/ShortOrLong" + $ref: '#/components/schemas/ShortOrLong' responses: 200: - description: "" + description: '' content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' /users: post: requestBody: - content : + content: application/json: schema: $ref: '#/components/schemas/User' responses: 200: - description: "" + description: '' content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' components: schemas: ObjectId: @@ -70,7 +70,7 @@ components: type: object properties: modificationDate: - $ref: "#/components/schemas/Date" + $ref: '#/components/schemas/Date' StringList: type: string format: string-list @@ -78,19 +78,19 @@ components: type: object properties: id: - $ref: "#/components/schemas/ObjectId" + $ref: '#/components/schemas/ObjectId' tags: - $ref: "#/components/schemas/StringList" + $ref: '#/components/schemas/StringList' creationDateTime: - $ref: "#/components/schemas/DateTime" + $ref: '#/components/schemas/DateTime' creationDate: - $ref: "#/components/schemas/Date" + $ref: '#/components/schemas/Date' shortOrLong: - $ref: "#/components/schemas/ShortOrLong" + $ref: '#/components/schemas/ShortOrLong' history: type: array items: - $ref: "#/components/schemas/HistoryItem" + $ref: '#/components/schemas/HistoryItem' historyWithoutRef: type: array items: @@ -99,4 +99,3 @@ components: modificationDate: type: string format: date - diff --git a/test/resources/821.yaml b/test/resources/821.yaml index e9533d76..edc85cf9 100644 --- a/test/resources/821.yaml +++ b/test/resources/821.yaml @@ -4,7 +4,7 @@ info: title: Test additionalProperties date-time paths: /test: - get: + get: responses: '200': description: foo diff --git a/test/resources/additional.props.query.params.yaml b/test/resources/additional.props.query.params.yaml index b75d7cd7..e9214e67 100644 --- a/test/resources/additional.props.query.params.yaml +++ b/test/resources/additional.props.query.params.yaml @@ -37,5 +37,3 @@ paths: responses: '200': description: the response - - diff --git a/test/resources/all.of.yaml b/test/resources/all.of.yaml index 7110589d..8a8c812c 100644 --- a/test/resources/all.of.yaml +++ b/test/resources/all.of.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.0" +openapi: '3.0.0' info: version: 1.0.0 title: Test @@ -13,10 +13,10 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Pet" + $ref: '#/components/schemas/Pet' responses: - "200": + '200': description: success components: @@ -37,7 +37,7 @@ components: # This causes AVJ validation to fail - https://github.com/epoberezkin/ajv/issues/837 # additionalProperties: false allOf: - - $ref: "#/components/schemas/NewPet" + - $ref: '#/components/schemas/NewPet' - required: - id type: object diff --git a/test/resources/circular.yaml b/test/resources/circular.yaml index f0a2397f..e6d580ca 100644 --- a/test/resources/circular.yaml +++ b/test/resources/circular.yaml @@ -14,7 +14,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: '#/components/schemas/User' responses: '200': description: Updated @@ -30,11 +30,9 @@ components: type: number name: type: string - favorite: + favorite: $ref: '#/components/schemas/User' children: type: array items: $ref: '#/components/schemas/User' - - \ No newline at end of file diff --git a/test/resources/coercion.yaml b/test/resources/coercion.yaml index 5e9344f4..9de59596 100644 --- a/test/resources/coercion.yaml +++ b/test/resources/coercion.yaml @@ -51,16 +51,16 @@ paths: description: Returns pets by name operationId: addPet parameters: - - in: query - name: filter - schema: - type: object - additionalProperties: false - properties: - names: - type: array - items: - type: string + - in: query + name: filter + schema: + type: object + additionalProperties: false + properties: + names: + type: array + items: + type: string responses: '200': description: pet response diff --git a/test/resources/controller-with-default.ts b/test/resources/controller-with-default.ts index b52090a2..442ca7c6 100644 --- a/test/resources/controller-with-default.ts +++ b/test/resources/controller-with-default.ts @@ -1,3 +1,3 @@ export default function (req, res) { - res.json({success: true}).end(); + res.json({ success: true }).end(); } diff --git a/test/resources/empty.servers.yaml b/test/resources/empty.servers.yaml index 621c6430..4fbbbf28 100644 --- a/test/resources/empty.servers.yaml +++ b/test/resources/empty.servers.yaml @@ -91,4 +91,3 @@ components: format: int32 message: type: string - diff --git a/test/resources/eov-operations.modulepath.yaml b/test/resources/eov-operations.modulepath.yaml index 8b0ca08c..1719a835 100644 --- a/test/resources/eov-operations.modulepath.yaml +++ b/test/resources/eov-operations.modulepath.yaml @@ -14,7 +14,7 @@ paths: get: description: | ping then pong! - operationId: ping.ping + operationId: ping.ping responses: '200': description: OK @@ -191,7 +191,7 @@ paths: summary: Get info about a User operationId: user.info security: [] - parameters: + parameters: - $ref: '#/components/parameters/userID' responses: '200': @@ -210,7 +210,7 @@ components: name: userID in: path required: true - schema: + schema: $ref: '#/components/schemas/UserID' # type: number diff --git a/test/resources/eov-operations.yaml b/test/resources/eov-operations.yaml index 5f8906e4..9c641f3d 100644 --- a/test/resources/eov-operations.yaml +++ b/test/resources/eov-operations.yaml @@ -15,8 +15,8 @@ paths: description: | ping then pong! # use operationId, (x-eov-operation-id is optional. it can be used in place of operationId or to override it) - operationId: ping - x-eov-operation-handler: routes/ping + operationId: ping + x-eov-operation-handler: routes/ping responses: '200': description: OK diff --git a/test/resources/escaped.characters.in.path.yaml b/test/resources/escaped.characters.in.path.yaml index 7a34bfd0..e2d9544c 100644 --- a/test/resources/escaped.characters.in.path.yaml +++ b/test/resources/escaped.characters.in.path.yaml @@ -1,11 +1,11 @@ openapi: '3.0.0' info: - description: "Some escaped characters in $ref" - version: "1.0.0" - title: "Source Code" + description: 'Some escaped characters in $ref' + version: '1.0.0' + title: 'Source Code' license: - name: "GPL-3.0-or-later" - url: "https://choosealicense.com/licenses/gpl-3.0/" + name: 'GPL-3.0-or-later' + url: 'https://choosealicense.com/licenses/gpl-3.0/' servers: - url: /v1/ @@ -32,4 +32,4 @@ components: description: Explanation about an error required: - message - - errors \ No newline at end of file + - errors diff --git a/test/resources/formats.yaml b/test/resources/formats.yaml index 6a29dc14..4dc9e9fa 100644 --- a/test/resources/formats.yaml +++ b/test/resources/formats.yaml @@ -7,7 +7,7 @@ servers: paths: /fees: get: - parameters: + parameters: - name: id in: query required: true @@ -26,7 +26,7 @@ paths: /formats/1: get: - parameters: + parameters: - name: string_id in: query schema: @@ -56,4 +56,3 @@ paths: responses: '200': description: response - diff --git a/test/resources/headers.yaml b/test/resources/headers.yaml index 3859efbf..e974b208 100644 --- a/test/resources/headers.yaml +++ b/test/resources/headers.yaml @@ -12,7 +12,7 @@ servers: paths: /headers_1: get: - operationId: ping + operationId: ping parameters: - name: x-userid in: header @@ -27,4 +27,4 @@ paths: text/plain: schema: type: string - example: headers_1 \ No newline at end of file + example: headers_1 diff --git a/test/resources/ignore.paths.yaml b/test/resources/ignore.paths.yaml index f2142f91..da4e151f 100644 --- a/test/resources/ignore.paths.yaml +++ b/test/resources/ignore.paths.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.0" +openapi: '3.0.0' info: version: 1.0.0 title: Swagger Petstore @@ -22,7 +22,7 @@ paths: schema: type: string responses: - "200": + '200': description: user response /pets/{id}: @@ -38,12 +38,12 @@ paths: type: integer format: int64 responses: - "200": + '200': description: pet response content: application/json: schema: - $ref: "#/components/schemas/Pet" + $ref: '#/components/schemas/Pet' /route_defined_in_openapi_only: get: @@ -56,7 +56,7 @@ paths: type: integer format: int64 responses: - "200": + '200': description: test components: diff --git a/test/resources/multipart.yaml b/test/resources/multipart.yaml index 64592f8a..765b1324 100644 --- a/test/resources/multipart.yaml +++ b/test/resources/multipart.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.0" +openapi: '3.0.0' info: version: 1.0.0 title: Swagger Petstore @@ -40,7 +40,7 @@ paths: p2: type: string responses: - "200": + '200': description: form data /sample_2: @@ -73,7 +73,7 @@ paths: form_p2: type: string responses: - "200": + '200': description: form data /sample_3: @@ -87,7 +87,7 @@ paths: type: string format: binary responses: - "200": + '200': description: binary /sample_4: @@ -153,7 +153,7 @@ paths: minimum: 5 maximum: 10 responses: - "200": + '200': description: form data components: diff --git a/test/resources/multiple-validations.yaml b/test/resources/multiple-validations.yaml index ed6a8bcc..6973d8ec 100644 --- a/test/resources/multiple-validations.yaml +++ b/test/resources/multiple-validations.yaml @@ -11,7 +11,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Person" + $ref: '#/components/schemas/Person' responses: 200: description: Success @@ -38,7 +38,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Person" + $ref: '#/components/schemas/Person' components: schemas: diff --git a/test/resources/nested.routes.yaml b/test/resources/nested.routes.yaml index 4e0450ca..e4e87234 100644 --- a/test/resources/nested.routes.yaml +++ b/test/resources/nested.routes.yaml @@ -69,4 +69,4 @@ components: type: integer format: int32 message: - type: string \ No newline at end of file + type: string diff --git a/test/resources/one.of.2.yaml b/test/resources/one.of.2.yaml index d954633f..5e9967c2 100644 --- a/test/resources/one.of.2.yaml +++ b/test/resources/one.of.2.yaml @@ -104,7 +104,7 @@ components: # add CatObject as an option # so that the non-mapping / implied mapping tests can pass enum: [cat, kitty, CatObject] - color: + color: type: string default: gray @@ -118,7 +118,7 @@ components: discriminator: propertyName: pet_type - Dog: # "Dog" is a value for the pet_type property (the discriminator value) + Dog: # "Dog" is a value for the pet_type property (the discriminator value) allOf: # Combines the main `Pet` schema with `Dog`-specific properties - $ref: '#/components/schemas/Pet' - type: object @@ -129,7 +129,7 @@ components: breed: type: string enum: [Dingo, Husky, Retriever, Shepherd] - Cat: # "Cat" is a value for the pet_type property (the discriminator value) + Cat: # "Cat" is a value for the pet_type property (the discriminator value) allOf: # Combines the main `Pet` schema with `Cat`-specific properties - $ref: '#/components/schemas/Pet' - type: object @@ -138,4 +138,4 @@ components: hunts: type: boolean age: - type: integer \ No newline at end of file + type: integer diff --git a/test/resources/one.of.yaml b/test/resources/one.of.yaml index cf638026..88ebf659 100644 --- a/test/resources/one.of.yaml +++ b/test/resources/one.of.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.2" +openapi: '3.0.2' info: version: 1.0.0 title: requestBodies $ref @@ -15,17 +15,17 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/OneOfType" + $ref: '#/components/schemas/OneOfType' responses: - "200": + '200': description: OK content: application/json: schema: $ref: '#/components/schemas/OneOfType' - "400": + '400': description: Bad Request - + /one_of_b: post: requestBody: @@ -33,22 +33,22 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/OneOfTypeB" + $ref: '#/components/schemas/OneOfTypeB' responses: - "200": + '200': description: OK content: application/json: schema: $ref: '#/components/schemas/OneOfType' - "400": + '400': description: Bad Request components: schemas: SimilarTypeOne: allOf: - - $ref: "#/components/schemas/SimilarSuperType" + - $ref: '#/components/schemas/SimilarSuperType' - type: object properties: type: @@ -63,7 +63,7 @@ components: SimilarTypeTwo: allOf: - - $ref: "#/components/schemas/SimilarSuperType" + - $ref: '#/components/schemas/SimilarSuperType' - type: object properties: type: @@ -83,14 +83,14 @@ components: type: array items: oneOf: - - $ref: "#/components/schemas/SimilarTypeOne" - - $ref: "#/components/schemas/SimilarTypeTwo" + - $ref: '#/components/schemas/SimilarTypeOne' + - $ref: '#/components/schemas/SimilarTypeTwo' discriminator: propertyName: type SimilarTypeOneB: allOf: - - $ref: "#/components/schemas/SimilarSuperTypeB" + - $ref: '#/components/schemas/SimilarSuperTypeB' properties: type: type: string @@ -101,7 +101,7 @@ components: value: type: number format: int32 - enum: [ 1 ] + enum: [1] default: 1 required: - type @@ -110,7 +110,7 @@ components: SimilarTypeTwoB: allOf: - - $ref: "#/components/schemas/SimilarSuperTypeB" + - $ref: '#/components/schemas/SimilarSuperTypeB' properties: type: type: string @@ -121,7 +121,7 @@ components: value: type: number format: int32 - enum: [ 2 ] + enum: [2] default: 2 required: - type @@ -135,8 +135,8 @@ components: type: array items: oneOf: - - $ref: "#/components/schemas/SimilarTypeOneB" - - $ref: "#/components/schemas/SimilarTypeTwoB" + - $ref: '#/components/schemas/SimilarTypeOneB' + - $ref: '#/components/schemas/SimilarTypeTwoB' discriminator: propertyName: type @@ -145,7 +145,7 @@ components: properties: id: type: string - + SimilarSuperTypeB: type: object properties: @@ -158,4 +158,3 @@ components: propertyName: type required: - value - diff --git a/test/resources/openapi.json b/test/resources/openapi.json index bc123cc9..dc65d468 100644 --- a/test/resources/openapi.json +++ b/test/resources/openapi.json @@ -1,578 +1,539 @@ { - "openapi": "3.0.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification", - "termsOfService": "http://swagger.io/terms/", - "contact": { - "name": "Swagger API Team", - "email": "apiteam@swagger.io", - "url": "http://swagger.io" - }, - "license": { - "name": "Apache 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "servers": [ - { - "url": "/v1/" - }, - { - "url": "http://{name}.swagger.io:{port}/{version}", - "variables": { - "name": { - "default": "petstore", - "enum": [ - "petstore", - "storeofpets" - ] - }, - "port": { - "enum": [ - "443", - "8443" - ], - "default": "443" - }, - "version": { - "default": "v1", - "enum": [ - "v1", - "v2" - ] - } - } - } - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", - "operationId": "findPets", - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "required": false, - "style": "form", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "required": true, - "schema": { - "type": "integer", - "format": "int32", - "minimum": 5 - } - }, - { - "name": "test", - "in": "query", - "description": "maximum number of results to return", - "required": true, - "schema": { - "type": "string", - "enum": [ - "one", - "two" - ] - } - }, - { - "name": "testJson", - "in": "query", - "description": "JSON in query params", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string", - "enum": [ - "bar", - "baz" - ] - } - } - } - } - } - }, - { - "name": "testArrayNoExplode", - "in": "query", - "description": "Array in query param", - "schema": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "foo", - "bar", - "baz" - ] - } - }, - "style": "form", - "explode": false - }, - { - "name": "testArrayNoExplode2", - "in": "query", - "description": "Array in query param", - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "form", - "explode": false - }, - { - "name": "testArrayExplode", - "in": "query", - "description": "Array explode in query param", - "schema": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "foo", - "bar", - "baz" - ] - } - }, - "style": "form", - "explode": true - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "requestBody": { - "description": "Pet to add to the store", - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/NewPet" - } - } - } - }, - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "find pet by id", - "parameters": [ - { - "$ref": "#/components/parameters/id" - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/pets/{id}/photos": { - "post": { - "description": "upload a photo of the pet", - "operationId": "uploadPetPhoto", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "required": [ - "file", - "metadata" - ], - "properties": { - "file": { - "description": "The photo", - "type": "string", - "format": "binary" - }, - "metadata": { - "type": "string" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "photo uploaded" - } - } - } - }, - "/pets/{id}/attributes": { - "get": { - "description": "Returns attributes for this pet", - "operationId": "find attributes", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "in": "header", - "name": "X-Attribute-Id", - "schema": { - "type": "string", - "format": "uuid" - }, - "required": true - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Attribute" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/pets/{id}/attributes/{attribute_id}": { - "get": { - "description": "Returns the attribute specified by attribute_id", - "operationId": "find attributes by pet id", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "in": "path", - "name": "attribute_id", - "schema": { - "type": "integer", - "format": "int64" - }, - "required": true - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Attribute" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/route_not_defined_within_express": { - "get": { - "description": "Returns attributes for this pet", - "operationId": "route-not-defined-within-express", - "parameters": [ - { - "name": "name", - "in": "query", - "description": "the name", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Attribute" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - } - }, - "components": { - "parameters": { - "id": { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - }, - "schemas": { - "NewPet": { - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "Pet": { - "allOf": [ - { - "$ref": "#/components/schemas/NewPet" - }, - { - "required": [ - "id" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - } - } - } - ] - }, - "NewAttribute": { - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - } - } - }, - "Attribute": { - "allOf": [ - { - "$ref": "#/components/schemas/NewAttribute" - }, - { - "required": [ - "id" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - } - } - } - ] - }, - "NewPhoto": { - "type": "object", - "required": [ - "file" - ], - "properties": { - "file": { - "description": "The photo", - "type": "string", - "format": "binary" - } - } - }, - "Error": { - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore", + "description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "Swagger API Team", + "email": "apiteam@swagger.io", + "url": "http://swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "servers": [ + { + "url": "/v1/" + }, + { + "url": "http://{name}.swagger.io:{port}/{version}", + "variables": { + "name": { + "default": "petstore", + "enum": ["petstore", "storeofpets"] + }, + "port": { + "enum": ["443", "8443"], + "default": "443" + }, + "version": { + "default": "v1", + "enum": ["v1", "v2"] + } + } + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "required": false, + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "required": true, + "schema": { + "type": "integer", + "format": "int32", + "minimum": 5 + } + }, + { + "name": "test", + "in": "query", + "description": "maximum number of results to return", + "required": true, + "schema": { + "type": "string", + "enum": ["one", "two"] + } + }, + { + "name": "testJson", + "in": "query", + "description": "JSON in query params", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "foo": { + "type": "string", + "enum": ["bar", "baz"] + } + } + } + } + } + }, + { + "name": "testArrayNoExplode", + "in": "query", + "description": "Array in query param", + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": ["foo", "bar", "baz"] + } + }, + "style": "form", + "explode": false + }, + { + "name": "testArrayNoExplode2", + "in": "query", + "description": "Array in query param", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "style": "form", + "explode": false + }, + { + "name": "testArrayExplode", + "in": "query", + "description": "Array explode in query param", + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": ["foo", "bar", "baz"] + } + }, + "style": "form", + "explode": true + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NewPet" + } + } + } + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "find pet by id", + "parameters": [ + { + "$ref": "#/components/parameters/id" + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/pets/{id}/photos": { + "post": { + "description": "upload a photo of the pet", + "operationId": "uploadPetPhoto", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "required": ["file", "metadata"], + "properties": { + "file": { + "description": "The photo", + "type": "string", + "format": "binary" + }, + "metadata": { + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "photo uploaded" + } + } + } + }, + "/pets/{id}/attributes": { + "get": { + "description": "Returns attributes for this pet", + "operationId": "find attributes", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "in": "header", + "name": "X-Attribute-Id", + "schema": { + "type": "string", + "format": "uuid" + }, + "required": true + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Attribute" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/pets/{id}/attributes/{attribute_id}": { + "get": { + "description": "Returns the attribute specified by attribute_id", + "operationId": "find attributes by pet id", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "in": "path", + "name": "attribute_id", + "schema": { + "type": "integer", + "format": "int64" + }, + "required": true + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Attribute" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/route_not_defined_within_express": { + "get": { + "description": "Returns attributes for this pet", + "operationId": "route-not-defined-within-express", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Attribute" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + } + }, + "components": { + "parameters": { + "id": { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + }, + "schemas": { + "NewPet": { + "required": ["name"], + "properties": { + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "Pet": { + "allOf": [ + { + "$ref": "#/components/schemas/NewPet" + }, + { + "required": ["id"], + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + ] + }, + "NewAttribute": { + "required": ["name"], + "properties": { + "name": { + "type": "string" + } + } + }, + "Attribute": { + "allOf": [ + { + "$ref": "#/components/schemas/NewAttribute" + }, + { + "required": ["id"], + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + ] + }, + "NewPhoto": { + "type": "object", + "required": ["file"], + "properties": { + "file": { + "description": "The photo", + "type": "string", + "format": "binary" + } + } + }, + "Error": { + "required": ["code", "message"], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } } diff --git a/test/resources/openapi.yaml b/test/resources/openapi.yaml index c5343611..d2470789 100644 --- a/test/resources/openapi.yaml +++ b/test/resources/openapi.yaml @@ -115,7 +115,7 @@ paths: - bar - baz style: form -# explode: true + # explode: true responses: '200': description: pet response diff --git a/test/resources/path.order.yaml b/test/resources/path.order.yaml index b6578542..7b660c30 100644 --- a/test/resources/path.order.yaml +++ b/test/resources/path.order.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.0" +openapi: '3.0.0' info: version: 1.0.0 title: Swagger Petstore @@ -22,12 +22,12 @@ paths: schema: type: string responses: - "200": + '200': description: user response content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' /users/jimmy: post: @@ -38,14 +38,14 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' responses: - "200": + '200': description: user response content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' components: schemas: diff --git a/test/resources/path.params.yaml b/test/resources/path.params.yaml index 014afadc..22d7a29b 100644 --- a/test/resources/path.params.yaml +++ b/test/resources/path.params.yaml @@ -1,7 +1,7 @@ -openapi: "3.0.0" +openapi: '3.0.0' info: - title: "Test for allOf" - version: "1" + title: 'Test for allOf' + version: '1' servers: - url: /v1/ paths: @@ -15,11 +15,11 @@ paths: type: string responses: 200: - description: "" + description: '' content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' /users_alt/{id}: parameters: - name: id @@ -30,11 +30,11 @@ paths: get: responses: 200: - description: "" + description: '' content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' /multi_users/{ids}: get: summary: Deletes Features given a number of uuids. @@ -48,13 +48,13 @@ paths: type: string style: simple responses: - "200": + '200': description: Features were successfully deleted content: application/json: schema: type: object - "/user_lookup:{name}": + '/user_lookup:{name}': get: parameters: - name: name @@ -64,15 +64,15 @@ paths: type: string responses: 200: - description: "" + description: '' content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' components: schemas: User: type: object properties: id: - type: "string" + type: 'string' diff --git a/test/resources/query.params.yaml b/test/resources/query.params.yaml index 599552d7..491a041b 100644 --- a/test/resources/query.params.yaml +++ b/test/resources/query.params.yaml @@ -44,7 +44,7 @@ paths: /allow_reserved: get: parameters: - - name: value + - name: value in: query required: true schema: @@ -57,7 +57,7 @@ paths: /allow_reserved/array_explode: get: parameters: - - name: value + - name: value in: query required: true schema: diff --git a/test/resources/query.serialization.yaml b/test/resources/query.serialization.yaml index 5ffb5d24..63d0139b 100644 --- a/test/resources/query.serialization.yaml +++ b/test/resources/query.serialization.yaml @@ -6,7 +6,7 @@ info: paths: /api/q_form_explode: get: - parameters: + parameters: - description: Description schema: title: State @@ -26,7 +26,7 @@ paths: /api/q_form_nexplode: get: - parameters: + parameters: - description: Description required: false explode: false @@ -37,7 +37,7 @@ paths: $ref: '#/components/schemas/Foo' description: A description name: state - in: query + in: query responses: 200: description: OK @@ -45,8 +45,7 @@ paths: 'application/json; charset=utf-8': schema: type: object - - + components: schemas: Foo: @@ -54,5 +53,3 @@ components: enum: - on - off - - \ No newline at end of file diff --git a/test/resources/read.only.yaml b/test/resources/read.only.yaml index ffc5670f..23978698 100644 --- a/test/resources/read.only.yaml +++ b/test/resources/read.only.yaml @@ -145,11 +145,11 @@ paths: application/json: schema: $ref: '#/components/schemas/ProductNested' - + /readonly_required_allof: post: description: readonly required - parameters: + parameters: - name: include_id in: query schema: @@ -162,7 +162,7 @@ paths: schema: type: object properties: - optional: + optional: type: string responses: '200': diff --git a/test/resources/response.object.serializer.yaml b/test/resources/response.object.serializer.yaml index dce9c369..955bc081 100644 --- a/test/resources/response.object.serializer.yaml +++ b/test/resources/response.object.serializer.yaml @@ -1,7 +1,7 @@ -openapi: "3.0.0" +openapi: '3.0.0' info: - title: "Test for allOf" - version: "1" + title: 'Test for allOf' + version: '1' servers: - url: /v1/ paths: @@ -59,7 +59,7 @@ components: User: type: object properties: - id: + id: type: number created_at: - $ref: "#/components/schemas/Date" + $ref: '#/components/schemas/Date' diff --git a/test/resources/response.validation.defaults.yaml b/test/resources/response.validation.defaults.yaml index 518adc85..0f532ebb 100644 --- a/test/resources/response.validation.defaults.yaml +++ b/test/resources/response.validation.defaults.yaml @@ -5,38 +5,38 @@ info: servers: - url: /v1 paths: - /default_inline: - get: - parameters: - - name: q - in: 'query' - required: true - schema: - type: string - responses: - '200': - description: Success - content: - 'application/json': - schema: - type: object - properties: - data: - description: Some data - type: string - required: - - data - default: - description: Unexpected error - content: - 'application/json': - schema: - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string \ No newline at end of file + /default_inline: + get: + parameters: + - name: q + in: 'query' + required: true + schema: + type: string + responses: + '200': + description: Success + content: + 'application/json': + schema: + type: object + properties: + data: + description: Some data + type: string + required: + - data + default: + description: Unexpected error + content: + 'application/json': + schema: + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string diff --git a/test/resources/response.validation.yaml b/test/resources/response.validation.yaml index 550c4b8e..e26437d6 100644 --- a/test/resources/response.validation.yaml +++ b/test/resources/response.validation.yaml @@ -49,7 +49,7 @@ paths: responses: '204': description: empty - + /boolean: description: get boolean responses get: diff --git a/test/resources/routes/pets.js b/test/resources/routes/pets.js index 3b3e8be0..7e85650b 100644 --- a/test/resources/routes/pets.js +++ b/test/resources/routes/pets.js @@ -24,7 +24,7 @@ module.exports = { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map(f => ({ + files_metadata: req.files.map((f) => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, @@ -55,7 +55,7 @@ module.exports = { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map(f => ({ + files_metadata: req.files.map((f) => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, diff --git a/test/resources/routes/user.js b/test/resources/routes/user.js index 9edb0b58..b51c5dae 100644 --- a/test/resources/routes/user.js +++ b/test/resources/routes/user.js @@ -1,3 +1,3 @@ module.exports = { - info: (req, res) => res.status(200).send({ id: req.params.userID }) + info: (req, res) => res.status(200).send({ id: req.params.userID }), }; diff --git a/test/resources/security.top.level.yaml b/test/resources/security.top.level.yaml index 7f6e9534..5fa4d6ea 100644 --- a/test/resources/security.top.level.yaml +++ b/test/resources/security.top.level.yaml @@ -43,7 +43,7 @@ paths: get: security: - ApiKeyQueryAuth: [] - parameters: + parameters: - name: param1 in: query schema: diff --git a/test/resources/security.yaml b/test/resources/security.yaml index 3e6d2c66..cb49385a 100644 --- a/test/resources/security.yaml +++ b/test/resources/security.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.2" +openapi: '3.0.2' info: version: 1.0.0 title: requestBodies $ref @@ -15,15 +15,15 @@ paths: BearerAuth: [] - BasicAuth: [] responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized /no_security: get: responses: - "200": + '200': description: OK /api_key: @@ -31,9 +31,9 @@ paths: security: - ApiKeyAuth: [] responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized /api_key_or_anonymous: @@ -43,9 +43,9 @@ paths: - {} - ApiKeyAuth: [] responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized # This api key with scopes should fail validation and return 500 @@ -53,11 +53,11 @@ paths: /api_key_with_scopes: get: security: - - ApiKeyAuth: ["read", "write"] + - ApiKeyAuth: ['read', 'write'] responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized /bearer: @@ -65,9 +65,9 @@ paths: security: - BearerAuth: [] responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized /basic: @@ -75,9 +75,9 @@ paths: security: - BasicAuth: [] responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized /cookie_auth: @@ -85,9 +85,9 @@ paths: security: - CookieAuth: [] responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized /multi_auth: @@ -98,9 +98,9 @@ paths: - BasicAuth: [] CookieAuth: [] responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized /oauth2: @@ -110,9 +110,9 @@ paths: - scope1 - scope2 responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized /openid: @@ -122,9 +122,9 @@ paths: - scope1 - scope2 responses: - "200": + '200': description: OK - "401": + '401': description: unauthorized components: diff --git a/test/resources/serdes.yaml b/test/resources/serdes.yaml index 6a4f29ed..41e1f48a 100644 --- a/test/resources/serdes.yaml +++ b/test/resources/serdes.yaml @@ -1,7 +1,7 @@ -openapi: "3.0.0" +openapi: '3.0.0' info: - title: "Test for allOf" - version: "1" + title: 'Test for allOf' + version: '1' servers: - url: /v1/ paths: @@ -12,7 +12,7 @@ paths: in: path required: true schema: - $ref: "#/components/schemas/ObjectId" + $ref: '#/components/schemas/ObjectId' - name: date-time-from-inline in: query required: false @@ -23,7 +23,7 @@ paths: in: query required: false schema: - $ref: "#/components/schemas/DateTime" + $ref: '#/components/schemas/DateTime' - name: baddateresponse in: query schema: @@ -33,15 +33,15 @@ paths: in: query required: false schema: - $ref: "#/components/schemas/ShortOrLong" + $ref: '#/components/schemas/ShortOrLong' responses: 200: - description: "" + description: '' content: application/json: schema: allOf: - - $ref: "#/components/schemas/User" + - $ref: '#/components/schemas/User' - type: object properties: summary: @@ -56,7 +56,7 @@ paths: /users: post: requestBody: - content : + content: application/json: schema: allOf: @@ -68,12 +68,12 @@ paths: format: date-time responses: 200: - description: "" + description: '' content: application/json: schema: allOf: - - $ref: "#/components/schemas/User" + - $ref: '#/components/schemas/User' - type: object properties: summary: @@ -110,12 +110,12 @@ components: type: object properties: id: - $ref: "#/components/schemas/ObjectId" + $ref: '#/components/schemas/ObjectId' tags: - $ref: "#/components/schemas/StringList" + $ref: '#/components/schemas/StringList' creationDateTime: - $ref: "#/components/schemas/DateTime" + $ref: '#/components/schemas/DateTime' creationDate: - $ref: "#/components/schemas/Date" + $ref: '#/components/schemas/Date' shortOrLong: - $ref: "#/components/schemas/ShortOrLong" + $ref: '#/components/schemas/ShortOrLong' diff --git a/test/resources/serialized-deep-object.objects.yaml b/test/resources/serialized-deep-object.objects.yaml index 4ede419f..0517f3c6 100644 --- a/test/resources/serialized-deep-object.objects.yaml +++ b/test/resources/serialized-deep-object.objects.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.2" +openapi: '3.0.2' info: version: 1.0.0 title: Request Query Serialization @@ -12,7 +12,7 @@ paths: x-vendorExtension1: accounts get: x-vendorExtension2: accounts - summary: "retrieve a deep object" + summary: 'retrieve a deep object' operationId: getDeepObject parameters: - in: query @@ -31,21 +31,21 @@ paths: minItems: 1 state: type: string - enum: ["default", "validated", "pending"] - default: "default" + enum: ['default', 'validated', 'pending'] + default: 'default' description: "Filter the tags by their validity. The default value ('default') stands for no filtering." greeting: type: string - default: "hello" + default: 'hello' responses: - "200": + '200': description: the object /deep_object_2: get: parameters: - - $ref: '#/components/parameters/pedestrian' + - $ref: '#/components/parameters/pedestrian' responses: - "200": + '200': description: the object components: @@ -76,7 +76,7 @@ components: # greeting: # type: string # default: "hello" - + parameters: pedestrian: name: pedestrian diff --git a/test/resources/serialized.objects.defaults.yaml b/test/resources/serialized.objects.defaults.yaml index 4cd9e9ec..cd892729 100644 --- a/test/resources/serialized.objects.defaults.yaml +++ b/test/resources/serialized.objects.defaults.yaml @@ -2,8 +2,8 @@ components: schemas: PageSort: allOf: - - $ref: "#/components/schemas/Paging" - - $ref: "#/components/schemas/Sorting" + - $ref: '#/components/schemas/Paging' + - $ref: '#/components/schemas/Sorting' Paging: properties: page: @@ -47,10 +47,10 @@ paths: in: query name: pagesort schema: - $ref: "#/components/schemas/PageSort" + $ref: '#/components/schemas/PageSort' style: deepObject responses: - "200": + '200': description: description content: application/json: diff --git a/test/resources/serialized.objects.yaml b/test/resources/serialized.objects.yaml index bdf62637..8c36004b 100644 --- a/test/resources/serialized.objects.yaml +++ b/test/resources/serialized.objects.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.2" +openapi: '3.0.2' info: version: 1.0.0 title: Request Query Serialization @@ -12,7 +12,7 @@ paths: x-vendorExtension1: accounts get: x-vendorExtension2: accounts - summary: "retrieve a deep object" + summary: 'retrieve a deep object' operationId: getDeepObject parameters: - in: query @@ -30,19 +30,19 @@ paths: minItems: 1 state: type: string - enum: ["default", "validated", "pending"] - default: "default" + enum: ['default', 'validated', 'pending'] + default: 'default' description: "Filter the tags by their validity. The default value ('default') stands for no filtering." greeting: type: string - default: "hello" + default: 'hello' responses: - "200": + '200': description: the object /deep_object_2: get: - summary: "retrieve a deep object" + summary: 'retrieve a deep object' operationId: getDeepObject2 parameters: - in: query @@ -52,11 +52,11 @@ paths: schema: $ref: '#/components/schemas/Deep' responses: - "200": + '200': description: the object /tags: get: - summary: "Retrieve all tags" + summary: 'Retrieve all tags' operationId: getTags parameters: - in: query @@ -74,15 +74,15 @@ paths: minItems: 1 state: type: string - enum: ["default", "validated", "pending"] - default: "default" + enum: ['default', 'validated', 'pending'] + default: 'default' description: "Filter the tags by their validity. The default value ('default') stands for no filtering." responses: - "200": - description: "An array of tag" + '200': + description: 'An array of tag' /serialisable: get: - summary: "Retrieve something" + summary: 'Retrieve something' parameters: - in: query style: form @@ -109,7 +109,7 @@ paths: description: Should not be serialized schema: description: Value passed to Javascript's `new Date()`. - example: "2019-06-24T12:34:56.789Z" + example: '2019-06-24T12:34:56.789Z' anyOf: - type: integer description: Unix milliseconds @@ -134,7 +134,7 @@ paths: required: - foo responses: - "200": + '200': description: parsed & validated query params content: application/json: @@ -143,7 +143,7 @@ paths: components: schemas: - Deep: + Deep: type: object properties: tag_ids: @@ -154,9 +154,9 @@ components: minItems: 1 state: type: string - enum: ["default", "validated", "pending"] - default: "default" + enum: ['default', 'validated', 'pending'] + default: 'default' description: "Filter the tags by their validity. The default value ('default') stands for no filtering." greeting: type: string - default: "hello" + default: 'hello' diff --git a/test/resources/servers.1.yaml b/test/resources/servers.1.yaml index eeed9719..11d3a218 100644 --- a/test/resources/servers.1.yaml +++ b/test/resources/servers.1.yaml @@ -18,7 +18,7 @@ servers: paths: /ping: get: - parameters: + parameters: - name: id in: query required: true diff --git a/test/resources/servers.2.yaml b/test/resources/servers.2.yaml index bdd805a2..77e6c3e8 100644 --- a/test/resources/servers.2.yaml +++ b/test/resources/servers.2.yaml @@ -18,7 +18,7 @@ servers: paths: /ping: get: - parameters: + parameters: - name: id in: query required: true diff --git a/test/resources/services/index.js b/test/resources/services/index.js index 1c7afd6e..d7822814 100644 --- a/test/resources/services/index.js +++ b/test/resources/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter(d => d.type === type).slice(0, limit); + return data.filter((d) => d.type === type).slice(0, limit); } findById(id) { - return data.filter(p => p.id === id)[0]; + return data.filter((p) => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter(e => e.id !== id); + return data.filter((e) => e.id !== id); } -} +}; diff --git a/test/resources/sub_files/paths/auth.yaml b/test/resources/sub_files/paths/auth.yaml index d5860cf4..50ce1f2c 100644 --- a/test/resources/sub_files/paths/auth.yaml +++ b/test/resources/sub_files/paths/auth.yaml @@ -1,7 +1,7 @@ paths: /auth/login: post: - summary: "Logs user into the system" + summary: 'Logs user into the system' operationId: signIn tags: - guest @@ -10,7 +10,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Auth" + $ref: '#/components/schemas/Auth' responses: '200': description: A JSON containing the JWT Token and some information about the user @@ -18,7 +18,7 @@ paths: application/json: schema: allOf: - - $ref: "#/components/schemas/JWTToken" + - $ref: '#/components/schemas/JWTToken' - type: object description: Some basic information on this user properties: @@ -27,14 +27,14 @@ paths: properties: fullName: type: string - description: "The full name of this user" - example: "Eric Cartman" + description: 'The full name of this user' + example: 'Eric Cartman' minLength: 1 maxLength: 50 role: type: string enum: [admin, user] - description: "What kind of user are we ?" + description: 'What kind of user are we ?' required: - fullName - role @@ -42,14 +42,14 @@ paths: - user # Definition of all error statuses default: - description: "Whatever error : 4XX - Client error (Bad Request, Unauthorized, etc.) , 5XX - Server error" + description: 'Whatever error : 4XX - Client error (Bad Request, Unauthorized, etc.) , 5XX - Server error' content: application/json: schema: - $ref: "#/components/schemas/ErrorObject" + $ref: '#/components/schemas/ErrorObject' /auth/register: post: - summary: "Creates a new user into the system" + summary: 'Creates a new user into the system' operationId: register tags: - guest @@ -59,13 +59,13 @@ paths: application/json: schema: allOf: - - $ref: "#/components/schemas/Auth" + - $ref: '#/components/schemas/Auth' - type: object properties: fullName: type: string - example: "Some User" - description: "The full name of this new user" + example: 'Some User' + description: 'The full name of this new user' minLength: 1 maxLength: 50 required: @@ -75,11 +75,11 @@ paths: description: OK # Definition of all error statuses default: - description: "Whatever error : 4XX - Client error (Bad Request, Unauthorized, etc.) , 5XX - Server error" + description: 'Whatever error : 4XX - Client error (Bad Request, Unauthorized, etc.) , 5XX - Server error' content: application/json: schema: - $ref: "#/components/schemas/ErrorObject" + $ref: '#/components/schemas/ErrorObject' components: schemas: @@ -89,11 +89,11 @@ components: email: type: string format: email - example: "jy95@perdu.com" + example: 'jy95@perdu.com' password: type: string format: password - example: "42" + example: '42' required: - email - password @@ -118,4 +118,4 @@ components: description: Explanation about an error required: - message - - errors \ No newline at end of file + - errors diff --git a/test/resources/unknown.formats.yaml b/test/resources/unknown.formats.yaml index 95735e5c..82acca03 100644 --- a/test/resources/unknown.formats.yaml +++ b/test/resources/unknown.formats.yaml @@ -3,7 +3,7 @@ info: title: Formats version: 1.0.0 servers: -- url: /v1 + - url: /v1 paths: /persons: post: @@ -16,12 +16,11 @@ paths: 200: description: Invalid ID supplied - components: schemas: Person: required: - - id + - id type: object properties: id: @@ -32,4 +31,4 @@ components: hypertext: type: string format: hypertext - example: "

Hello. I am..." \ No newline at end of file + example: '

Hello. I am...' diff --git a/test/resources/unknown.keywords.yaml b/test/resources/unknown.keywords.yaml index b254d601..9938f5eb 100644 --- a/test/resources/unknown.keywords.yaml +++ b/test/resources/unknown.keywords.yaml @@ -3,7 +3,7 @@ info: title: Keywords version: 1.0.0 servers: -- url: /v1 + - url: /v1 paths: /persons: post: @@ -21,7 +21,7 @@ components: schemas: Person: required: - - id + - id type: object x-custom-keyword: Ignored by validator. properties: diff --git a/test/resources/wildcard.path.params.yaml b/test/resources/wildcard.path.params.yaml index 13bf3a4a..b84b50e8 100644 --- a/test/resources/wildcard.path.params.yaml +++ b/test/resources/wildcard.path.params.yaml @@ -3,7 +3,7 @@ info: title: dummy api version: 1.0.0 servers: -- url: /v1 + - url: /v1 paths: /d1/{id}: @@ -91,4 +91,4 @@ paths: responses: 200: description: dummy response - content: {} \ No newline at end of file + content: {} diff --git a/test/resources/write.only.yaml b/test/resources/write.only.yaml index cf8d62e1..9868f07d 100644 --- a/test/resources/write.only.yaml +++ b/test/resources/write.only.yaml @@ -15,7 +15,7 @@ paths: post: description: create products operationId: createProductsInline - parameters: + parameters: - name: exclude_write_only in: query schema: @@ -50,7 +50,7 @@ paths: post: description: create products operationId: createProductsNested - parameters: + parameters: - name: exclude_write_only in: query schema: @@ -96,7 +96,7 @@ components: ProductNested: type: object required: - - "password" + - 'password' properties: id: type: string @@ -126,7 +126,7 @@ components: Review: type: object required: - - "review_password" + - 'review_password' properties: id: type: integer diff --git a/test/resources/xt.newpet.yaml b/test/resources/xt.newpet.yaml index 971d0750..86bea101 100644 --- a/test/resources/xt.newpet.yaml +++ b/test/resources/xt.newpet.yaml @@ -7,4 +7,4 @@ NewPet: type: string nullable: true tag: - type: string \ No newline at end of file + type: string diff --git a/test/resources/xt.openapi.parameters.yaml b/test/resources/xt.openapi.parameters.yaml index 105f04c9..a262f7d1 100644 --- a/test/resources/xt.openapi.parameters.yaml +++ b/test/resources/xt.openapi.parameters.yaml @@ -6,4 +6,4 @@ parameters: required: true schema: type: integer - format: int64 \ No newline at end of file + format: int64 diff --git a/test/response.object.serializer.spec.ts b/test/response.object.serializer.spec.ts index ffffeb6c..3d0b13d5 100644 --- a/test/response.object.serializer.spec.ts +++ b/test/response.object.serializer.spec.ts @@ -31,10 +31,12 @@ describe('response serializer', () => { app.get([`${app.basePath}/array-of-date-times`], (req, res) => { let date = new Date('2020-12-20T07:28:19.213Z'); res.json({ - users: [{ - id: req.params.id, - created_at: date, - }], + users: [ + { + id: req.params.id, + created_at: date, + }, + ], }); }); app.get([`${app.basePath}/date`], (req, res) => { @@ -80,7 +82,9 @@ describe('response serializer', () => { .get(`${app.basePath}/array-of-date-times`) .expect(200) .then((r) => { - expect(r.body.users[0].created_at).to.equal('2020-12-20T07:28:19.213Z'); + expect(r.body.users[0].created_at).to.equal( + '2020-12-20T07:28:19.213Z', + ); })); }); }); diff --git a/test/response.validation.coerce.types.spec.ts b/test/response.validation.coerce.types.spec.ts index f13108a1..b36c14e1 100644 --- a/test/response.validation.coerce.types.spec.ts +++ b/test/response.validation.coerce.types.spec.ts @@ -48,7 +48,5 @@ describe('response validation with type coercion', () => { expect(r.body).to.equal(true); })); it('should coerce id from string to number', async () => - request(app) - .get(`${app.basePath}/object`) - .expect(200)); + request(app).get(`${app.basePath}/object`).expect(200)); }); diff --git a/test/response.validation.on.error.spec.ts b/test/response.validation.on.error.spec.ts index 36ad9643..465a9a38 100644 --- a/test/response.validation.on.error.spec.ts +++ b/test/response.validation.on.error.spec.ts @@ -16,16 +16,16 @@ describe(packageJson.name, () => { { apiSpec: apiSpecPath, validateResponses: { - onError: function(_err, body) { + onError: function (_err, body) { onErrorArgs = Array.from(arguments); if (body[0].id === 'bad_id_throw') { throw new Error('error in onError handler'); } - } + }, }, }, 3005, - app => { + (app) => { app.get(`${app.basePath}/users`, (_req, res) => { const json = ['user1', 'user2', 'user3']; return res.json(json); @@ -52,7 +52,7 @@ describe(packageJson.name, () => { afterEach(() => { onErrorArgs = null; - }) + }); after(() => { app.server.close(); @@ -66,10 +66,12 @@ describe(packageJson.name, () => { const data = [{ id: 'bad_id', name: 'name', tag: 'tag' }]; expect(r.body).to.eql(data); expect(onErrorArgs.length).to.equal(3); - expect(onErrorArgs[0].message).to.equal('/response/0/id must be integer'); + expect(onErrorArgs[0].message).to.equal( + '/response/0/id must be integer', + ); expect(onErrorArgs[1]).to.eql(data); expect(onErrorArgs[2].query).to.eql({ - mode: 'bad_type' + mode: 'bad_type', }); })); @@ -90,7 +92,9 @@ describe(packageJson.name, () => { const data = [{ id: 'bad_id_throw', name: 'name', tag: 'tag' }]; expect(r.body.message).to.equal('error in onError handler'); expect(onErrorArgs.length).to.equal(3); - expect(onErrorArgs[0].message).to.equal('/response/0/id must be integer'); + expect(onErrorArgs[0].message).to.equal( + '/response/0/id must be integer', + ); expect(onErrorArgs[1]).to.eql(data); })); }); diff --git a/test/response.validator.spec.ts b/test/response.validator.spec.ts index 09b06c78..10c353bc 100644 --- a/test/response.validator.spec.ts +++ b/test/response.validator.spec.ts @@ -17,10 +17,10 @@ const fakeReq: OpenApiRequest = { describe(packageJson.name, () => { it('should validate the using default (in this case the error object)', async () => { const v = new ResponseValidator(cloneDeep(apiSpec), { - formats: { - 'date-time': true, - }, - strict: false, + formats: { + 'date-time': true, + }, + strict: false, }); const responses = petsResponseSchema(); const validators = v._getOrBuildValidator(fakeReq, responses); @@ -42,10 +42,10 @@ describe(packageJson.name, () => { it('should throw error when default response is invalid', async () => { const v = new ResponseValidator(apiSpec, { - formats: { - 'date-time': true, - }, - strict: false, + formats: { + 'date-time': true, + }, + strict: false, }); const responses = petsResponseSchema(); const validators = v._getOrBuildValidator(fakeReq, responses); @@ -71,10 +71,10 @@ describe(packageJson.name, () => { it('should return an error if field type is invalid', async () => { const v = new ResponseValidator(apiSpec, { - formats: { - 'date-time': true, - }, - strict: false, + formats: { + 'date-time': true, + }, + strict: false, }); const responses = petsResponseSchema(); const validators = v._getOrBuildValidator(fakeReq, responses); diff --git a/test/security.defaults.spec.ts b/test/security.defaults.spec.ts index 18bbeee5..02019e80 100644 --- a/test/security.defaults.spec.ts +++ b/test/security.defaults.spec.ts @@ -22,7 +22,7 @@ describe('security.defaults', () => { .get(`/bearer`, (req, res) => res.json({ logged_in: true })) .get(`/basic`, (req, res) => res.json({ logged_in: true })) .get('/no_security', (req, res) => res.json({ logged_in: true })) - .get('/multi_auth', (req, res) => res.json({ logged_in: true })) + .get('/multi_auth', (req, res) => res.json({ logged_in: true })), ); }); @@ -62,36 +62,36 @@ describe('security.defaults', () => { .then((r) => { expect(r.body) .to.have.property('message') - .that.equals('cookie \'JSESSIONID\' required'); + .that.equals("cookie 'JSESSIONID' required"); }); }); - it("Should return 200 WHEN one of multiple security rules is met GIVEN a request with apiKey and bearer token", () => { + it('Should return 200 WHEN one of multiple security rules is met GIVEN a request with apiKey and bearer token', () => { return request(app) .get(`${basePath}/multi_auth`) .set({ - "Authorization": "Bearer rawww", - "X-API-Key": "hello world" + Authorization: 'Bearer rawww', + 'X-API-Key': 'hello world', }) - .expect(200) - }) + .expect(200); + }); - it("Should return 200 WHEN one of multiple security rules is met GIVEN a request with cookie and basic auth", () => { + it('Should return 200 WHEN one of multiple security rules is met GIVEN a request with cookie and basic auth', () => { return request(app) .get(`${basePath}/multi_auth`) .set({ - "Authorization": "Basic ZGVtbzpwQDU1dzByZA==", - "Cookie": "JSESSIONID=dwdwdwdwd" + Authorization: 'Basic ZGVtbzpwQDU1dzByZA==', + Cookie: 'JSESSIONID=dwdwdwdwd', }) - .expect(200) - }) + .expect(200); + }); - it("Should return 401 WHEN none of multiple security rules is met GIVEN a request with only cookie auth", () => { + it('Should return 401 WHEN none of multiple security rules is met GIVEN a request with only cookie auth', () => { return request(app) .get(`${basePath}/multi_auth`) .set({ - "Cookie": "JSESSIONID=dwdwdwdwd" + Cookie: 'JSESSIONID=dwdwdwdwd', }) - .expect(401) - }) + .expect(401); + }); }); diff --git a/test/security.disabled.spec.ts b/test/security.disabled.spec.ts index 610c0bf3..9e0c75b6 100644 --- a/test/security.disabled.spec.ts +++ b/test/security.disabled.spec.ts @@ -29,19 +29,13 @@ describe('security.disabled', () => { }); it('should return 200 if no security', async () => - request(app) - .get(`${basePath}/no_security`) - .expect(200)); + request(app).get(`${basePath}/no_security`).expect(200)); it('should skip validation, even if auth header is missing for basic auth', async () => { - return request(app) - .get(`${basePath}/basic`) - .expect(200); + return request(app).get(`${basePath}/basic`).expect(200); }); it('should skip security validation, even if auth header is missing for bearer auth', async () => { - return request(app) - .get(`${basePath}/bearer`) - .expect(200); + return request(app).get(`${basePath}/bearer`).expect(200); }); }); diff --git a/test/security.top.level.spec.ts b/test/security.top.level.spec.ts index 8f8641a8..e5113494 100644 --- a/test/security.top.level.spec.ts +++ b/test/security.top.level.spec.ts @@ -38,7 +38,7 @@ describe('security.top.level', () => { request(app) .get(`${basePath}/api_key`) .expect(401) - .then(r => { + .then((r) => { const body = r.body; expect(body.errors).to.be.an('array'); expect(body.errors).to.have.length(1); @@ -56,7 +56,7 @@ describe('security.top.level', () => { .get(`${basePath}/api_key_undefined_path`) .set('X-API-Key', 'test') .expect(404) - .then(r => { + .then((r) => { const body = r.body; expect(body.errors).to.be.an('array'); expect(body.errors).to.have.length(1); @@ -68,7 +68,7 @@ describe('security.top.level', () => { .post(`${basePath}/api_key`) .set('X-API-Key', 'test') .expect(405) - .then(r => { + .then((r) => { const body = r.body; expect(body.errors).to.be.an('array'); expect(body.errors).to.have.length(1); @@ -98,15 +98,13 @@ describe('security.top.level', () => { .expect(200), ); it('should return 200 if apikey or anonymous', async () => - request(app) - .get(`${basePath}/api_key_or_anonymous`) - .expect(200)); + request(app).get(`${basePath}/api_key_or_anonymous`).expect(200)); it('should override api key with bearer and return 401 if bearer is missing', async () => request(app) .get(`${basePath}/bearer`) .expect(401) - .then(r => { + .then((r) => { const body = r.body; expect(body.errors).to.be.an('array'); expect(body.errors).to.have.length(1); @@ -122,12 +120,8 @@ describe('security.top.level', () => { .expect(200)); it('should override api key with anonymous', async () => - request(app) - .get(`${basePath}/anonymous_2`) - .expect(200)); + request(app).get(`${basePath}/anonymous_2`).expect(200)); it('should override api key with anonymous', async () => - request(app) - .get(`${basePath}/anonymous`) - .expect(200)); + request(app).get(`${basePath}/anonymous`).expect(200)); }); diff --git a/test/serdes.spec.ts b/test/serdes.spec.ts index 25774403..e3504b4e 100644 --- a/test/serdes.spec.ts +++ b/test/serdes.spec.ts @@ -10,19 +10,18 @@ const apiSpecPath = path.join('test', 'resources', 'serdes.yaml'); class ObjectID { id: string; - constructor(id: string = "5fdefd13a6640bb5fb5fa925") { + constructor(id: string = '5fdefd13a6640bb5fb5fa925') { this.id = id; } toString() { return this.id; } - } class BadDate extends Date { public toISOString(): string { - return "oh no a bad iso date"; + return 'oh no a bad iso date'; } } @@ -30,9 +29,9 @@ function toSummary(title, value) { return { [title]: { value: value?.toISOString?.() || value?.toString(), - typeof: typeof value - } - } + typeof: typeof value, + }, + }; } describe('serdes', () => { @@ -44,16 +43,16 @@ describe('serdes', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true + coerceTypes: true, }, validateResponses: { - coerceTypes: true + coerceTypes: true, }, serDes: [ date, dateTime, { - format: "mongo-objectid", + format: 'mongo-objectid', deserialize: (s) => new ObjectID(s), serialize: (o) => o.toString(), }, @@ -64,36 +63,54 @@ describe('serdes', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'object') { - throw new Error("Should be deserialized to ObjectId object"); + throw new Error('Should be deserialized to ObjectId object'); } - let date = new Date("2020-12-20T07:28:19.213Z"); + let date = new Date('2020-12-20T07:28:19.213Z'); res.json({ id: req.params.id, creationDateTime: date, creationDate: date, shortOrLong: 'a', summary: { - ...toSummary('req.query.date-time-from-inline', req.query['date-time-from-inline']), - ...toSummary('req.query.date-time-from-schema', req.query['date-time-from-schema']), + ...toSummary( + 'req.query.date-time-from-inline', + req.query['date-time-from-inline'], + ), + ...toSummary( + 'req.query.date-time-from-schema', + req.query['date-time-from-schema'], + ), }, }); }); app.post([`${app.basePath}/users`], (req, res) => { if (typeof req.body.id !== 'object') { - throw new Error("Should be deserialized to ObjectId object"); + throw new Error('Should be deserialized to ObjectId object'); } - if (typeof req.body.creationDate !== 'object' || !(req.body.creationDate instanceof Date)) { - throw new Error("Should be deserialized to Date object"); + if ( + typeof req.body.creationDate !== 'object' || + !(req.body.creationDate instanceof Date) + ) { + throw new Error('Should be deserialized to Date object'); } - if (typeof req.body.creationDateTime !== 'object' || !(req.body.creationDateTime instanceof Date)) { - throw new Error("Should be deserialized to Date object"); + if ( + typeof req.body.creationDateTime !== 'object' || + !(req.body.creationDateTime instanceof Date) + ) { + throw new Error('Should be deserialized to Date object'); } - if (typeof req.body.creationDateTimeInline !== 'object' || !(req.body.creationDateTimeInline instanceof Date)) { - throw new Error("Should be deserialized to Date object"); + if ( + typeof req.body.creationDateTimeInline !== 'object' || + !(req.body.creationDateTimeInline instanceof Date) + ) { + throw new Error('Should be deserialized to Date object'); } res.json({ ...req.body, - summary: Object.entries(req.body).reduce((acc, [k, v]) => Object.assign(acc, toSummary(k, v)), {}) + summary: Object.entries(req.body).reduce( + (acc, [k, v]) => Object.assign(acc, toSummary(k, v)), + {}, + ), }); }); app.use((err, req, res, next) => { @@ -105,7 +122,7 @@ describe('serdes', () => { }, false, ); - return app + return app; }); after(() => { @@ -117,21 +134,33 @@ describe('serdes', () => { .get(`${app.basePath}/users/1234`) .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/params/id must match pattern "^[0-9a-fA-F]{24}$"'); + expect(r.body.message).to.equal( + 'request/params/id must match pattern "^[0-9a-fA-F]{24}$"', + ); })); it('should control GOOD id format and get a response in expected format', async () => request(app) - .get(`${app.basePath}/users/5fdefd13a6640bb5fb5fa925?date-time-from-inline=2019-11-20T01%3A11%3A54.930Z&date-time-from-schema=2020-11-20T01%3A11%3A54.930Z`) + .get( + `${app.basePath}/users/5fdefd13a6640bb5fb5fa925?date-time-from-inline=2019-11-20T01%3A11%3A54.930Z&date-time-from-schema=2020-11-20T01%3A11%3A54.930Z`, + ) .expect(200) .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); - expect(r.body.summary['req.query.date-time-from-schema'].value).to.equal("2020-11-20T01:11:54.930Z"); - expect(r.body.summary['req.query.date-time-from-schema'].typeof).to.equal("object"); - expect(r.body.summary['req.query.date-time-from-inline'].value).to.equal("2019-11-20T01:11:54.930Z"); - expect(r.body.summary['req.query.date-time-from-inline'].typeof).to.equal("object"); + expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); + expect( + r.body.summary['req.query.date-time-from-schema'].value, + ).to.equal('2020-11-20T01:11:54.930Z'); + expect( + r.body.summary['req.query.date-time-from-schema'].typeof, + ).to.equal('object'); + expect( + r.body.summary['req.query.date-time-from-inline'].value, + ).to.equal('2019-11-20T01:11:54.930Z'); + expect( + r.body.summary['req.query.date-time-from-inline'].typeof, + ).to.equal('object'); })); it('should POST also works with deserialize on request then serialize en response', async () => @@ -149,13 +178,21 @@ describe('serdes', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); - expect(r.body.summary['creationDate'].value).to.equal('2020-12-20T00:00:00.000Z'); + expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); + expect(r.body.summary['creationDate'].value).to.equal( + '2020-12-20T00:00:00.000Z', + ); expect(r.body.summary['creationDate'].typeof).to.equal('object'); - expect(r.body.summary['creationDateTime'].value).to.equal('2020-12-20T07:28:19.213Z'); + expect(r.body.summary['creationDateTime'].value).to.equal( + '2020-12-20T07:28:19.213Z', + ); expect(r.body.summary['creationDateTime'].typeof).to.equal('object'); - expect(r.body.summary['creationDateTimeInline'].value).to.equal('2019-11-21T07:24:19.213Z'); - expect(r.body.summary['creationDateTimeInline'].typeof).to.equal('object'); + expect(r.body.summary['creationDateTimeInline'].value).to.equal( + '2019-11-21T07:24:19.213Z', + ); + expect(r.body.summary['creationDateTimeInline'].typeof).to.equal( + 'object', + ); })); it('should POST throw error on invalid schema ObjectId', async () => @@ -170,7 +207,9 @@ describe('serdes', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/id must match pattern "^[0-9a-fA-F]{24}$"'); + expect(r.body.message).to.equal( + 'request/body/id must match pattern "^[0-9a-fA-F]{24}$"', + ); })); it('should POST throw error on invalid schema Date', async () => @@ -179,12 +218,14 @@ describe('serdes', () => { .send({ id: '5fdefd13a6640bb5fb5fa925', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-1f-20' + creationDate: '2020-1f-20', }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/creationDate must match format "date"'); + expect(r.body.message).to.equal( + 'request/body/creationDate must match format "date"', + ); })); it('should enforce anyOf validations', async () => @@ -209,8 +250,6 @@ describe('serdes', () => { })); }); - - describe('serdes serialize response components only', () => { let app = null; @@ -220,16 +259,16 @@ describe('serdes serialize response components only', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true + coerceTypes: true, }, validateResponses: { - coerceTypes: true + coerceTypes: true, }, serDes: [ date.serializer, dateTime.serializer, { - format: "mongo-objectid", + format: 'mongo-objectid', serialize: (o) => o.toString(), }, ], @@ -239,9 +278,9 @@ describe('serdes serialize response components only', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'string') { - throw new Error("Should be not be deserialized to ObjectId object"); + throw new Error('Should be not be deserialized to ObjectId object'); } - let date = new Date("2020-12-20T07:28:19.213Z"); + let date = new Date('2020-12-20T07:28:19.213Z'); let result = { id: new ObjectID(req.params.id), creationDateTime: date, @@ -250,24 +289,22 @@ describe('serdes serialize response components only', () => { }; if (req.query.baddateresponse === 'functionNotExists') { result.creationDate = new ObjectID(); - } - else if (req.query.baddateresponse === 'functionBadFormat') { + } else if (req.query.baddateresponse === 'functionBadFormat') { result.creationDate = new BadDate(); - } - else { + } else { result.creationDate = date; } res.json(result); }); app.post([`${app.basePath}/users`], (req, res) => { if (typeof req.body.id !== 'string') { - throw new Error("Should NOT be deserialized to ObjectId object"); + throw new Error('Should NOT be deserialized to ObjectId object'); } if (typeof req.body.creationDate !== 'string') { - throw new Error("Should NTO be deserialized to Date object"); + throw new Error('Should NTO be deserialized to Date object'); } if (typeof req.body.creationDateTime !== 'string') { - throw new Error("Should NOT be deserialized to Date object"); + throw new Error('Should NOT be deserialized to Date object'); } req.body.id = new ObjectID(req.body.id); req.body.creationDateTime = new Date(req.body.creationDateTime); @@ -283,7 +320,7 @@ describe('serdes serialize response components only', () => { }, false, ); - return app + return app; }); after(() => { @@ -295,7 +332,9 @@ describe('serdes serialize response components only', () => { .get(`${app.basePath}/users/1234`) .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/params/id must match pattern "^[0-9a-fA-F]{24}$"'); + expect(r.body.message).to.equal( + 'request/params/id must match pattern "^[0-9a-fA-F]{24}$"', + ); })); it('should control GOOD id format and get a response in expected format', async () => @@ -305,7 +344,7 @@ describe('serdes serialize response components only', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); + expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); })); it('should POST also works with deserialize on request then serialize en response', async () => @@ -314,14 +353,14 @@ describe('serdes serialize response components only', () => { .send({ id: '5fdefd13a6640bb5fb5fa925', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-12-20' + creationDate: '2020-12-20', }) .set('Content-Type', 'application/json') .expect(200) .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); + expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); })); it('should POST throw error on invalid schema ObjectId', async () => @@ -330,12 +369,14 @@ describe('serdes serialize response components only', () => { .send({ id: '5fdefd13a6640bb5fb5fa', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-12-20' + creationDate: '2020-12-20', }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/id must match pattern "^[0-9a-fA-F]{24}$"'); + expect(r.body.message).to.equal( + 'request/body/id must match pattern "^[0-9a-fA-F]{24}$"', + ); })); it('should POST throw error on invalid schema Date', async () => @@ -344,12 +385,14 @@ describe('serdes serialize response components only', () => { .send({ id: '5fdefd13a6640bb5fb5fa925', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-1f-20' + creationDate: '2020-1f-20', }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/creationDate must match format "date"'); + expect(r.body.message).to.equal( + 'request/body/creationDate must match format "date"', + ); })); it('should throw error 500 on invalid object type instead of Date expected', async () => @@ -397,7 +440,6 @@ describe('serdes serialize response components only', () => { })); */ - }); describe('serdes with array type string-list', () => { @@ -409,22 +451,22 @@ describe('serdes with array type string-list', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true + coerceTypes: true, }, validateResponses: { - coerceTypes: true + coerceTypes: true, }, serDes: [ date, dateTime, { - format: "mongo-objectid", + format: 'mongo-objectid', deserialize: (s) => new ObjectID(s), serialize: (o) => o.toString(), }, { format: 'string-list', - deserialize: (s): string[] => s.split(',').map(s => s.trim()), + deserialize: (s): string[] => s.split(',').map((s) => s.trim()), serialize: (o): string => (o as string[]).join(','), }, ], @@ -433,28 +475,34 @@ describe('serdes with array type string-list', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'object') { - throw new Error("Should be deserialized to ObjectId object"); + throw new Error('Should be deserialized to ObjectId object'); } - let date = new Date("2020-12-20T07:28:19.213Z"); + let date = new Date('2020-12-20T07:28:19.213Z'); res.json({ id: req.params.id, tags: ['aa', 'bb', 'cc'], creationDateTime: date, - creationDate: date + creationDate: date, }); }); app.post([`${app.basePath}/users`], (req, res) => { if (typeof req.body.id !== 'object') { - throw new Error("Should be deserialized to ObjectId object"); + throw new Error('Should be deserialized to ObjectId object'); } if (!Array.isArray(req.body.tags)) { - throw new Error("Should be deserialized to an Array object"); + throw new Error('Should be deserialized to an Array object'); } - if (typeof req.body.creationDate !== 'object' || !(req.body.creationDate instanceof Date)) { - throw new Error("Should be deserialized to Date object"); + if ( + typeof req.body.creationDate !== 'object' || + !(req.body.creationDate instanceof Date) + ) { + throw new Error('Should be deserialized to Date object'); } - if (typeof req.body.creationDateTime !== 'object' || !(req.body.creationDateTime instanceof Date)) { - throw new Error("Should be deserialized to Date object"); + if ( + typeof req.body.creationDateTime !== 'object' || + !(req.body.creationDateTime instanceof Date) + ) { + throw new Error('Should be deserialized to Date object'); } res.json(req.body); }); @@ -467,7 +515,7 @@ describe('serdes with array type string-list', () => { }, false, ); - return app + return app; }); after(() => { @@ -479,7 +527,9 @@ describe('serdes with array type string-list', () => { .get(`${app.basePath}/users/1234`) .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/params/id must match pattern "^[0-9a-fA-F]{24}$"'); + expect(r.body.message).to.equal( + 'request/params/id must match pattern "^[0-9a-fA-F]{24}$"', + ); })); it('should control GOOD id format and get a response in expected format', async () => { @@ -489,12 +539,11 @@ describe('serdes with array type string-list', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); + expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); expect(r.body.tags).to.equal('aa,bb,cc'); - }) + }); }); - it('should POST also works with deserialize on request then serialize en response', async () => request(app) .post(`${app.basePath}/users`) @@ -510,7 +559,7 @@ describe('serdes with array type string-list', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); + expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); expect(r.body.tags).to.equal('aa,bb,cc'); })); @@ -521,12 +570,14 @@ describe('serdes with array type string-list', () => { id: '5fdefd13a6640bb5fb5fa', tags: 'aa,bb,cc', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-12-20' + creationDate: '2020-12-20', }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/id must match pattern "^[0-9a-fA-F]{24}$"'); + expect(r.body.message).to.equal( + 'request/body/id must match pattern "^[0-9a-fA-F]{24}$"', + ); })); it('should POST throw error on invalid schema Date', async () => @@ -536,12 +587,14 @@ describe('serdes with array type string-list', () => { id: '5fdefd13a6640bb5fb5fa925', tags: 'aa,bb,cc', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-1f-20' + creationDate: '2020-1f-20', }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal('request/body/creationDate must match format "date"'); + expect(r.body.message).to.equal( + 'request/body/creationDate must match format "date"', + ); })); it('should POST throw error for deserialize on request of non-string format', async () => @@ -551,7 +604,7 @@ describe('serdes with array type string-list', () => { id: '5fdefd13a6640bb5fb5fa925', tags: ['aa', 'bb', 'cc'], creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-12-20' + creationDate: '2020-12-20', }) .set('Content-Type', 'application/json') .expect(400) @@ -580,5 +633,3 @@ describe('serdes with array type string-list', () => { ); })); }); - - diff --git a/test/servers.spec.ts b/test/servers.spec.ts index ed229c29..f525f28c 100644 --- a/test/servers.spec.ts +++ b/test/servers.spec.ts @@ -14,9 +14,15 @@ describe(packageJson.name, () => { }, 3005, (app) => { - app.get(`/api/v1/petstore/ping`, (req, res) => res.json({ ...req.body })); - app.get(`/api/v2/storeofpets/ping`, (req, res) => res.json({ ...req.body })); - app.get(`/api/v3/petstore/ping`, (req, res) => res.json({ ...req.body })); + app.get(`/api/v1/petstore/ping`, (req, res) => + res.json({ ...req.body }), + ); + app.get(`/api/v2/storeofpets/ping`, (req, res) => + res.json({ ...req.body }), + ); + app.get(`/api/v3/petstore/ping`, (req, res) => + res.json({ ...req.body }), + ); }, true, ); @@ -31,43 +37,48 @@ describe(packageJson.name, () => { request(app).get('/api/v2/storeofpets/ping').send({}).expect(400)); it('should skip validation of api path with invalid enum value v3, and valid value petstore', async () => - // the validator should not validate routes that do note match one declare in the opeanpi apec - // in this case, 'v3' is not a valid value for api - // TODO throw an error instead of ignoring it + // the validator should not validate routes that do note match one declare in the opeanpi apec + // in this case, 'v3' is not a valid value for api + // TODO throw an error instead of ignoring it request(app).get('/api/v3/petstore/ping').send({}).expect(200)); }); describe(packageJson.name, () => { - let app = null; - - before(async () => { - const apiSpec = path.join('test', 'resources', 'servers.2.yaml'); - app = await createApp( - { - apiSpec, - }, - 3005, - (app) => { - app.get(`/api/v1:petstore/ping`, (req, res) => res.json({ ...req.body })); - app.get(`/api/v2:storeofpets/ping`, (req, res) => res.json({ ...req.body })); - app.get(`/api/v3:petstore/ping`, (req, res) => res.json({ ...req.body })); - }, - true, - ); - }); - - after(() => app.server.close()); - - it('should validate server path with version variables, v2 and petstore', async () => - request(app).get('/api/v1:petstore/ping').query({}).expect(400)); - - it('should validate server path with version variables, v2 and storeofpets', async () => - request(app).get('/api/v2:storeofpets/ping').send({}).expect(400)); - - it('should skip validation of api path with invalid variable value, v2, and valid variable petstore', async () => - // the validator should not validate routes that do note match one declare in the opeanpi apec - // in this case, 'v3' is not a valid value for api - // TODO throw an error instead of ignoring it - request(app).get('/api/v3:petstore/ping').send({}).expect(200)); + let app = null; + + before(async () => { + const apiSpec = path.join('test', 'resources', 'servers.2.yaml'); + app = await createApp( + { + apiSpec, + }, + 3005, + (app) => { + app.get(`/api/v1:petstore/ping`, (req, res) => + res.json({ ...req.body }), + ); + app.get(`/api/v2:storeofpets/ping`, (req, res) => + res.json({ ...req.body }), + ); + app.get(`/api/v3:petstore/ping`, (req, res) => + res.json({ ...req.body }), + ); + }, + true, + ); }); - \ No newline at end of file + + after(() => app.server.close()); + + it('should validate server path with version variables, v2 and petstore', async () => + request(app).get('/api/v1:petstore/ping').query({}).expect(400)); + + it('should validate server path with version variables, v2 and storeofpets', async () => + request(app).get('/api/v2:storeofpets/ping').send({}).expect(400)); + + it('should skip validation of api path with invalid variable value, v2, and valid variable petstore', async () => + // the validator should not validate routes that do note match one declare in the opeanpi apec + // in this case, 'v3' is not a valid value for api + // TODO throw an error instead of ignoring it + request(app).get('/api/v3:petstore/ping').send({}).expect(200)); +}); From 189d6249b43b2de73ddb026a8619cf6d9d827629 Mon Sep 17 00:00:00 2001 From: Maximilian Mayer Date: Mon, 13 Jan 2025 14:57:42 +0100 Subject: [PATCH 2/3] fix/strip-all-examples-from-openapi-spec --- src/framework/openapi.spec.loader.ts | 3 + src/framework/openapi/strip.examples.ts | 208 +++++++++++++++++++ src/framework/types.ts | 6 +- src/middlewares/openapi.request.validator.ts | 2 - test/ignore.examples.spec.ts | 143 +++++++++++++ 5 files changed, 357 insertions(+), 5 deletions(-) create mode 100644 src/framework/openapi/strip.examples.ts create mode 100644 test/ignore.examples.spec.ts diff --git a/src/framework/openapi.spec.loader.ts b/src/framework/openapi.spec.loader.ts index b43d95ef..06e76e36 100644 --- a/src/framework/openapi.spec.loader.ts +++ b/src/framework/openapi.spec.loader.ts @@ -5,6 +5,7 @@ import { OpenAPIV3, OpenAPIFrameworkArgs, } from './types'; +import { stripExamples } from './openapi/strip.examples'; export interface Spec { apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; @@ -103,6 +104,8 @@ export class OpenApiSpecLoader { routes.sort(sortRoutes); + stripExamples(apiDoc); + serial = serial + 1; return { apiDoc, diff --git a/src/framework/openapi/strip.examples.ts b/src/framework/openapi/strip.examples.ts new file mode 100644 index 00000000..4036c77d --- /dev/null +++ b/src/framework/openapi/strip.examples.ts @@ -0,0 +1,208 @@ +import { OpenAPIV3 } from '../types'; + +export function stripExamples( + document: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, +): void { + stripExamplesFromPaths(document.paths); + stripExamplesFromComponents(document.components); + + if (isDocumentV3_1(document)) { + stripExamplesFromPaths(document.components?.pathItems); + stripExamplesFromPaths(document.webhooks); + } +} + +function stripExamplesFromPaths(path?: OpenAPIV3.PathsObject): void { + if (hasNoExamples(path)) return; + forEachValue(path, (pathItem) => stripExamplesFromPathItem(pathItem)); +} + +function stripExamplesFromComponents( + components?: OpenAPIV3.ComponentsObject, +): void { + if (hasNoExamples(components)) return; + + delete components.examples; + + stripExamplesFromSchema(components.schemas); + stripExamplesFromResponses(components.responses); + stripExamplesFromHeaders(components.headers); + stripExamplesFromCallbacks(components.callbacks); + + forEachValue(components.requestBodies, (requestBody) => + stripExamplesFromRequestBody(requestBody), + ); + + if (components.parameters !== undefined) { + stripExamplesFromParameters( + Object.entries(components.parameters).map( + ([_key, parameter]) => parameter, + ), + ); + } +} + +function stripExamplesFromPathItem( + pathItem?: OpenAPIV3.ReferenceObject | OpenAPIV3.PathItemObject, +): void { + // Explicitly not checking whether pathItem is a ReferenceObject, as + // there is no way to differentiate them. Attempt to remove all example + // properties either way. + if (pathItem === undefined) return; + + ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'].forEach( + (method) => { + stripExamplesFromOperation(pathItem[method]); + }, + ); + + if ('parameters' in pathItem) { + stripExamplesFromParameters(pathItem.parameters); + } +} + +function stripExamplesFromSchema( + schema?: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject, +): void { + if (hasNoExamples(schema)) return; + + if (schema.type !== 'array') { + stripExamplesFromBaseSchema(schema); + return; + } + + if ('items' in schema) { + stripExamplesFromSchema(schema.items); + } else { + stripExamplesFromSchema(schema.not); + (['allOf', 'oneOf', 'anyOf'] as const).forEach((property) => { + schema[property].forEach((childObject) => + stripExamplesFromSchema(childObject), + ); + }); + } +} + +function stripExamplesFromBaseSchema( + baseSchema?: OpenAPIV3.BaseSchemaObject, +): void { + if (hasNoExamples(baseSchema)) return; + + if (typeof baseSchema.additionalProperties !== 'boolean') { + stripExamplesFromSchema(baseSchema.additionalProperties); + } + + forEachValue(baseSchema.properties, (schema) => + stripExamplesFromSchema(schema), + ); +} + +function stripExamplesFromOperation( + operation?: OpenAPIV3.OperationObject, +): void { + if (hasNoExamples(operation)) return; + stripExamplesFromParameters(operation.parameters); + stripExamplesFromRequestBody(operation.requestBody); + stripExamplesFromResponses(operation.responses); + stripExamplesFromCallbacks(operation.callbacks); +} + +function stripExamplesFromRequestBody( + requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject, +): void { + if (hasNoExamples(requestBody)) return; + stripExamplesFromContent(requestBody.content); +} + +function stripExamplesFromResponses( + responses?: OpenAPIV3.ReferenceObject | OpenAPIV3.ResponsesObject, +): void { + if (hasNoExamples(responses)) return; + forEachValue(responses, (response) => { + if ('$ref' in response) { + return; + } + stripExamplesFromHeaders(response.headers); + stripExamplesFromContent(response.content); + }); +} + +function stripExamplesFromEncoding(encoding?: OpenAPIV3.EncodingObject): void { + if (hasNoExamples(encoding)) return; + stripExamplesFromHeaders(encoding.headers); +} + +function stripExamplesFromHeaders(headers?: { + [header: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.HeaderObject; +}): void { + if (hasNoExamples(headers)) return; + forEachValue(headers, (header) => stripExamplesFromParameterBase(header)); +} + +function stripExamplesFromContent(content?: { + [media: string]: OpenAPIV3.MediaTypeObject; +}): void { + forEachValue(content, (mediaTypeObject) => { + if (hasNoExamples(mediaTypeObject)) return; + + delete mediaTypeObject.example; + delete mediaTypeObject.examples; + + stripExamplesFromSchema(mediaTypeObject.schema); + forEachValue(mediaTypeObject.encoding, (encoding) => + stripExamplesFromEncoding(encoding), + ); + }); +} + +function stripExamplesFromParameters( + parameters?: Array, +): void { + if (hasNoExamples(parameters)) return; + parameters.forEach((parameter) => stripExamplesFromParameterBase(parameter)); +} + +function stripExamplesFromParameterBase( + parameterBase?: OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterBaseObject, +): void { + if (hasNoExamples(parameterBase)) return; + + delete parameterBase.example; + delete parameterBase.examples; + + stripExamplesFromSchema(parameterBase.schema); + stripExamplesFromContent(parameterBase.content); +} + +function stripExamplesFromCallbacks(callbacks?: { + [callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject; +}): void { + if (hasNoExamples(callbacks)) return; + + forEachValue(callbacks, (callback) => { + if ('$ref' in callback) { + return; + } + stripExamplesFromPaths(callback); + }); +} + +function isDocumentV3_1( + document: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, +): document is OpenAPIV3.DocumentV3_1 { + return document.openapi.startsWith('3.1.'); +} + +function hasNoExamples( + object: T | OpenAPIV3.ReferenceObject | undefined, +): object is OpenAPIV3.ReferenceObject | undefined { + return object === undefined || '$ref' in object; +} + +function forEachValue( + dictionary: { [key: string]: Value } | undefined, + perform: (value: Value) => void, +): void { + if (dictionary === undefined) return; + Object.entries(dictionary).forEach(([_key, value]) => perform(value)); +} diff --git a/src/framework/types.ts b/src/framework/types.ts index d533aa17..bd8d0762 100644 --- a/src/framework/types.ts +++ b/src/framework/types.ts @@ -1,7 +1,7 @@ import * as ajv from 'ajv'; import * as multer from 'multer'; import { FormatsPluginOptions } from 'ajv-formats'; -import { Request, Response, NextFunction, RequestHandler } from 'express'; +import { Request, Response, NextFunction } from 'express'; import { RouteMetadata } from './openapi.spec.loader'; import AjvDraft4 from 'ajv-draft-04'; import Ajv2020 from 'ajv/dist/2020'; @@ -312,7 +312,7 @@ export namespace OpenAPIV3 { export interface HeaderObject extends ParameterBaseObject {} - interface ParameterBaseObject { + export interface ParameterBaseObject { description?: string; required?: boolean; deprecated?: boolean; @@ -357,7 +357,7 @@ export namespace OpenAPIV3 { discriminator?: DiscriminatorObject; } - interface BaseSchemaObject { + export interface BaseSchemaObject { // JSON schema allowed properties, adjusted for OpenAPI type?: T; title?: string; diff --git a/src/middlewares/openapi.request.validator.ts b/src/middlewares/openapi.request.validator.ts index cb4de75d..180ddebd 100644 --- a/src/middlewares/openapi.request.validator.ts +++ b/src/middlewares/openapi.request.validator.ts @@ -42,8 +42,6 @@ export class RequestValidator { ) { this.middlewareCache = {}; this.apiDoc = apiDoc; - // Examples not needed for validation - delete this.apiDoc.components?.examples; this.requestOpts.allowUnknownQueryParameters = options.allowUnknownQueryParameters; diff --git a/test/ignore.examples.spec.ts b/test/ignore.examples.spec.ts new file mode 100644 index 00000000..ee39c6bc --- /dev/null +++ b/test/ignore.examples.spec.ts @@ -0,0 +1,143 @@ +import * as request from 'supertest'; +import { createApp } from './common/app'; +import * as packageJson from '../package.json'; + +describe(packageJson.name, () => { + let app = null; + + before(async () => { + // set up express app + app = await createApp( + { + apiSpec: apiSpec(), + validateRequests: true, + validateResponses: true, + }, + 3001, + (app) => { + app.post('/ping', (req: any, res: any) => { + res.json({ + id: req.body.id, + message: 'Pong!', + }); + }); + }, + false, + ); + }); + + after(() => { + app.server.close(); + }); + + it('should not throw an error when more than one example uses the same the value for a property "id"', async () => + request(app) + .post('/ping') + .send({ id: 'id', message: 'Ping!' }) + .expect(200)); +}); + +function apiSpec(): any { + return { + openapi: '3.0.0', + info: { + version: 'v1', + title: 'Validation Error', + description: + 'A test spec that triggers an validation error on identical id fields in examples.', + }, + paths: { + '/ping': { + post: { + description: 'ping then pong!', + operationId: 'ping', + requestBody: { + required: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Data', + }, + examples: { + request1: { + summary: 'Request 1', + value: { + id: 'Some_ID_A', + message: 'Ping!', + }, + }, + request2: { + summary: 'Request 2', + value: { + id: 'Some_ID_A', + message: 'Ping!', + }, + }, + }, + }, + }, + }, + responses: { + '200': { + description: 'OK', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/Data', + }, + examples: { + response1: { + summary: 'Response 1', + value: { + id: 'Some_ID_B', + message: 'Pong!', + }, + }, + response2: { + summary: 'Response 2', + value: { + id: 'Some_ID_B', + message: 'Pong!', + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + components: { + schemas: { + Data: { + required: ['id', 'message'], + properties: { + id: { + type: 'string', + }, + message: { + type: 'string', + }, + }, + }, + }, + examples: { + example1: { + summary: 'Example 1', + value: { + id: 'Some_ID_C', + message: 'Example!', + }, + }, + response2: { + summary: 'Example 2', + value: { + id: 'Some_ID_C', + message: 'Example!', + }, + }, + }, + }, + }; +} From 8dfdb94a3807c93df71a84bb3adcbf14aeb42138 Mon Sep 17 00:00:00 2001 From: Maximilian Mayer Date: Mon, 13 Jan 2025 15:54:29 +0100 Subject: [PATCH 3/3] chore/undo-prettier-for-smaller-PR-size --- .github/ISSUE_TEMPLATE/bug_report.md | 3 +- .github/ISSUE_TEMPLATE/feature_request.md | 1 + .github/dependabot.yml | 7 +- .github/workflows/default.yml | 2 +- .travis.yml | 28 +- CHANGE_HISTORY.md | 542 ++++---- CODE_OF_CONDUCT.md | 26 +- CONTRIBUTING.md | 13 +- README.md | 6 +- SECURITY.md | 1 + _config.yml | 2 +- examples/1-standard-oas-3.1/README.md | 12 +- examples/1-standard-oas-3.1/app.js | 1 + examples/1-standard-oas-3.1/services/index.js | 13 +- examples/1-standard/services/index.js | 6 +- examples/3-eov-operations/routes/pets.js | 2 +- examples/3-eov-operations/services/index.js | 8 +- examples/4-eov-operations-babel/.babelrc | 18 +- examples/4-eov-operations-babel/src/api.yaml | 4 +- .../4-eov-operations-babel/src/routes/pets.js | 2 +- .../src/services/index.js | 8 +- .../5-custom-operation-resolver/README.md | 10 +- examples/5-custom-operation-resolver/api.yaml | 2 +- .../routes/pets.js | 2 +- .../services/index.js | 8 +- examples/6-multi-file-spec/README.md | 7 +- examples/6-multi-file-spec/ems.yaml | 2 +- .../6-multi-file-spec/schemas/queries.yaml | 2 +- .../schemas/queryrequest.yaml | 2 +- .../schemas/queryrequests.yaml | 2 +- .../7-response-date-serialization/api.yaml | 7 +- launch.json | 1 + src/framework/ajv/factory.ts | 16 +- src/framework/ajv/index.ts | 32 +- src/framework/ajv/options.ts | 18 +- src/framework/base.path.ts | 16 +- src/framework/base.serdes.ts | 17 +- src/framework/index.ts | 4 +- src/framework/json.ref.schema.ts | 1 + src/framework/modded.express.mung.ts | 18 +- src/framework/openapi.context.ts | 4 +- src/framework/openapi.schema.validator.ts | 10 +- src/framework/openapi.spec.loader.ts | 12 +- src/framework/openapi/assert.version.ts | 16 +- src/framework/openapi/factory.schema.ts | 8 +- src/framework/types.ts | 67 +- src/middlewares/openapi.metadata.ts | 4 +- src/middlewares/openapi.multipart.ts | 6 +- src/middlewares/openapi.request.validator.ts | 8 +- src/middlewares/openapi.security.ts | 36 +- src/middlewares/parsers/body.parse.ts | 21 +- .../parsers/req.parameter.mutator.ts | 35 +- src/middlewares/parsers/schema.parse.ts | 5 +- .../parsers/schema.preprocessor.ts | 47 +- src/middlewares/util.ts | 29 +- src/openapi.validator.ts | 40 +- src/resolvers.ts | 5 +- test/1022.spec.ts | 4 +- test/356.campaign.spec.ts | 2 +- test/356.campaign.yaml | 6 +- test/440.spec.ts | 23 +- test/577.spec.ts | 17 +- test/699.spec.ts | 126 +- test/821.spec.ts | 31 +- .../ajv.resolves.more.than.one.schema.spec.ts | 46 +- test/common/app.common.ts | 103 +- test/common/app.ts | 2 +- test/common/test.yaml | 2 +- test/component.params.spec.ts | 4 +- test/content.type.spec.ts | 5 +- test/datetime.validation.spec.ts | 31 +- test/default-export.spec.ts | 4 +- test/default.export.fn.spec.ts | 8 +- test/escaped.characters.in.ref.path.spec.ts | 57 +- test/headers.2.spec.ts | 4 +- test/headers.spec.ts | 12 +- test/httperror.spec.ts | 4 +- test/ignore.paths.spec.ts | 16 +- test/multi.spec.spec.ts | 2 +- test/multipart.disabled.spec.ts | 14 +- test/multipart.spec.ts | 9 +- test/nested.routes.spec.ts | 27 +- test/one.of.spec.ts | 14 +- test/oneof.readonly.yaml | 90 +- test/openapi.spec.ts | 74 +- test/openapi_3.1/components.spec.ts | 11 +- .../openapi_3.1/components_path_items.spec.ts | 31 +- test/openapi_3.1/info_summary.spec.ts | 18 +- test/openapi_3.1/license_identifier.spec.ts | 18 +- ...non_defined_semantics_request_body.spec.ts | 28 +- test/openapi_3.1/path_no_response.spec.ts | 31 +- test/openapi_3.1/resources/components.yaml | 2 +- .../resources/components_path_items.yaml | 10 +- test/openapi_3.1/resources/info_summary.yaml | 2 +- .../resources/license_identifier.yaml | 2 +- .../non_defined_semantics_request_body.yaml | 6 +- .../resources/path_no_response.yaml | 2 +- .../resources/server_variable_no_default.yaml | 3 +- test/openapi_3.1/resources/type_null.yaml | 27 +- .../resources/unevaluated_properties.yaml | 2 +- test/openapi_3.1/resources/webhook.yaml | 6 +- test/openapi_3.1/server_variable.spec.ts | 21 +- test/openapi_3.1/type_null.spec.ts | 22 +- .../unevaluated_properties.spec.ts | 31 +- test/openapi_3.1/webhook.spec.ts | 11 +- test/optional-request-body.spec.ts | 4 +- test/path.level.parameters.spec.ts | 12 +- test/paths.sort.spec.ts | 6 +- test/query.params.allow.unknown.spec.ts | 4 +- test/query.params.spec.ts | 16 +- test/query.serialization.ts | 8 +- test/read.only.removeadditional.spec.ts | 153 ++- test/read.only.spec.ts | 10 +- test/request.bodies.ref.spec.ts | 4 +- test/resources/699.yaml | 35 +- test/resources/821.yaml | 2 +- .../additional.props.query.params.yaml | 2 + test/resources/all.of.yaml | 8 +- test/resources/circular.yaml | 6 +- test/resources/coercion.yaml | 20 +- test/resources/controller-with-default.ts | 2 +- test/resources/empty.servers.yaml | 1 + test/resources/eov-operations.modulepath.yaml | 6 +- test/resources/eov-operations.yaml | 4 +- .../resources/escaped.characters.in.path.yaml | 12 +- test/resources/formats.yaml | 5 +- test/resources/headers.yaml | 4 +- test/resources/ignore.paths.yaml | 10 +- test/resources/multipart.yaml | 10 +- test/resources/multiple-validations.yaml | 4 +- test/resources/nested.routes.yaml | 2 +- test/resources/one.of.2.yaml | 8 +- test/resources/one.of.yaml | 39 +- test/resources/openapi.json | 1113 +++++++++-------- test/resources/openapi.yaml | 2 +- test/resources/path.order.yaml | 12 +- test/resources/path.params.yaml | 24 +- test/resources/query.params.yaml | 4 +- test/resources/query.serialization.yaml | 11 +- test/resources/read.only.yaml | 6 +- .../resources/response.object.serializer.yaml | 10 +- .../response.validation.defaults.yaml | 70 +- test/resources/response.validation.yaml | 2 +- test/resources/routes/pets.js | 4 +- test/resources/routes/user.js | 2 +- test/resources/security.top.level.yaml | 2 +- test/resources/security.yaml | 46 +- test/resources/serdes.yaml | 32 +- .../serialized-deep-object.objects.yaml | 18 +- .../serialized.objects.defaults.yaml | 8 +- test/resources/serialized.objects.yaml | 40 +- test/resources/servers.1.yaml | 2 +- test/resources/servers.2.yaml | 2 +- test/resources/services/index.js | 8 +- test/resources/sub_files/paths/auth.yaml | 34 +- test/resources/unknown.formats.yaml | 7 +- test/resources/unknown.keywords.yaml | 4 +- test/resources/wildcard.path.params.yaml | 4 +- test/resources/write.only.yaml | 8 +- test/resources/xt.newpet.yaml | 2 +- test/resources/xt.openapi.parameters.yaml | 2 +- test/response.object.serializer.spec.ts | 14 +- test/response.validation.coerce.types.spec.ts | 4 +- test/response.validation.on.error.spec.ts | 18 +- test/response.validator.spec.ts | 24 +- test/security.defaults.spec.ts | 32 +- test/security.disabled.spec.ts | 12 +- test/security.top.level.spec.ts | 20 +- test/serdes.spec.ts | 225 ++-- test/servers.spec.ts | 87 +- 170 files changed, 2245 insertions(+), 2313 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b0b7948f..d28006d7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,6 +4,7 @@ about: Create a report to help us improve title: '' labels: '' assignees: '' + --- **Describe the bug** @@ -12,7 +13,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior. -**Actual behavior** +**Actual behavior** A clear and concise description of what happens. **Expected behavior** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 2f28cead..bbcbbe7d 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,6 +4,7 @@ about: Suggest an idea for this project title: '' labels: '' assignees: '' + --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 130464ae..6143fb25 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,8 @@ version: 2 updates: - - package-ecosystem: '' # See documentation for possible values - directory: '/' # Location of package manifests + - package-ecosystem: "" # See documentation for possible values + directory: "/" # Location of package manifests schedule: - interval: 'daily' + interval: "daily" + diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index b249178a..efbc4695 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -15,4 +15,4 @@ jobs: - name: Build the project run: npm run compile - name: Test the project - run: npm test + run: npm test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index f4c7a929..3d8e26f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,25 @@ sudo: required language: node_js node_js: - - '14' - - '12' - - '10' +- '14' +- '12' +- '10' before_install: - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_deba340dfe89_key -iv $encrypted_deba340dfe89_iv - -in secrets.zip.enc -out secrets.zip -d; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then unzip secrets.zip; fi' +- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_deba340dfe89_key -iv $encrypted_deba340dfe89_iv + -in secrets.zip.enc -out secrets.zip -d; fi' +- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then unzip secrets.zip; fi' install: - - npm install +- npm install script: - - npm run compile - - npm run test:coverage - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run coveralls; fi' - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run codacy; fi' +- npm run compile +- npm run test:coverage +- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run coveralls; fi' +- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run codacy; fi' env: global: - - secure: x+Nxbq8RrOVJyQ7JWNRpXdBmp61rXPKulYPxUwGeIe/ZJwX1QHsy2HAAB2m7aRvAMBAqr2urBaIKgPBmBklyY0elRTD/chUdT5cJiPhMIxBghqkQ1NYqx/WzcCBUrZbRzoQcpAES7sJnUs0PMujKv3wMsujoFJ9b9Z+trHMqD0IztBlg45azAh4A6ApVcDB8j4L+g42kps6d4r5jUt2d4uW537PKXpsnWJMaaj2Pw7pxU2H5kBaeNGnvlK+w9k3porToop7OUG+HBTN2BjofdF1PSHm8fizzFL6/h2x39cLYMxFvHb7oVUKBiWQe8PBXD5+k/X0RgPJMZO9AggMHln5MIihTowGvuSLK/3d95ta/qXTmzG0Csv4J8xWD+koCJm0xpSzsrBSUOPt5ZKN71o0VmLmc7U4Z0aEplZyVcMdTbwA1XeoeXD4UU1fD7BlzYl4oOTB8HlucJILwAZFg0upPB33lQchAUIgoUCDxze3OoG3V1Odcw4u64bXlPrdqgCg8AQZgnrYP+EzKczjGd7pBQZRVxKyq+44JV8JOUAXEka3qQRPvmw5wcAaXgsqU7uv1C6FcQb+j/ZKQ6GlWu8qDzouRR+OqbKeLk2lOvtU08Y32tn6u14+vVNbmsG3iXxGf2+esGcETFP/0EYluPGpo257h/9qC1yMN8ZExey0= - - secure: l5s8AWcMM9Ih8aq1OElM47vBI+NS06EB/7k19r7xsurU6+t7s1CoqdJn3HDzUfKax54HtJZzkbAAnfIhVJNIvC9srInW0fRCbD6hW9qS8o0HYDb7dakFa1/CxzoQv8Wz+xus9+Gx2IUJPGJ4ZzVGak704KW0Ds5CFnzQTorohyl/2a6jlODd2gAZMciJA0ZjQGiQPRYpt73cHa5QN03n5Buybp/m0ErsA2Wc7OZONTl0oW0hoQ0A8hICUP1nIbrZjavw8tIf5cComp9GxuatbFCRCaOu5kgbM/O5x0bKJkJutVabO1HC2dYd78o+X7e9ApH+Oly9cLEsuLyYLWnH5Kbdv2j/Huz6wP8H6is4FQUgasTUCcV5+9og6mSccoKDHIvuy0c5lkC30wuaiXJAAWSeohZ8lM6SnrDNp7Q+5mWx5ooVo4A6AGLdXNFeIkqmBat59eNijlnspkJ7MRp2+5mVI+rTyX+fwjLw6Z/1oY5GA9NY061+yPs8LL0BQYkm5r1et3lTIWGo3bJeLIZM4Dsh+VXv1Z8q7oz1PkhSwbmQH19FyQdeohgyzokidbQhGTgk8tO2ol1j2tZMPkwAh3MTRU4Gpmo641Qye69TMhBrhIb5ebmTFXt8HnRbfJT0x/hLjLdCd8hUzo27ICu7yCqZTR74RfIdBvIumSvGQJQ= + - secure: x+Nxbq8RrOVJyQ7JWNRpXdBmp61rXPKulYPxUwGeIe/ZJwX1QHsy2HAAB2m7aRvAMBAqr2urBaIKgPBmBklyY0elRTD/chUdT5cJiPhMIxBghqkQ1NYqx/WzcCBUrZbRzoQcpAES7sJnUs0PMujKv3wMsujoFJ9b9Z+trHMqD0IztBlg45azAh4A6ApVcDB8j4L+g42kps6d4r5jUt2d4uW537PKXpsnWJMaaj2Pw7pxU2H5kBaeNGnvlK+w9k3porToop7OUG+HBTN2BjofdF1PSHm8fizzFL6/h2x39cLYMxFvHb7oVUKBiWQe8PBXD5+k/X0RgPJMZO9AggMHln5MIihTowGvuSLK/3d95ta/qXTmzG0Csv4J8xWD+koCJm0xpSzsrBSUOPt5ZKN71o0VmLmc7U4Z0aEplZyVcMdTbwA1XeoeXD4UU1fD7BlzYl4oOTB8HlucJILwAZFg0upPB33lQchAUIgoUCDxze3OoG3V1Odcw4u64bXlPrdqgCg8AQZgnrYP+EzKczjGd7pBQZRVxKyq+44JV8JOUAXEka3qQRPvmw5wcAaXgsqU7uv1C6FcQb+j/ZKQ6GlWu8qDzouRR+OqbKeLk2lOvtU08Y32tn6u14+vVNbmsG3iXxGf2+esGcETFP/0EYluPGpo257h/9qC1yMN8ZExey0= + - secure: l5s8AWcMM9Ih8aq1OElM47vBI+NS06EB/7k19r7xsurU6+t7s1CoqdJn3HDzUfKax54HtJZzkbAAnfIhVJNIvC9srInW0fRCbD6hW9qS8o0HYDb7dakFa1/CxzoQv8Wz+xus9+Gx2IUJPGJ4ZzVGak704KW0Ds5CFnzQTorohyl/2a6jlODd2gAZMciJA0ZjQGiQPRYpt73cHa5QN03n5Buybp/m0ErsA2Wc7OZONTl0oW0hoQ0A8hICUP1nIbrZjavw8tIf5cComp9GxuatbFCRCaOu5kgbM/O5x0bKJkJutVabO1HC2dYd78o+X7e9ApH+Oly9cLEsuLyYLWnH5Kbdv2j/Huz6wP8H6is4FQUgasTUCcV5+9og6mSccoKDHIvuy0c5lkC30wuaiXJAAWSeohZ8lM6SnrDNp7Q+5mWx5ooVo4A6AGLdXNFeIkqmBat59eNijlnspkJ7MRp2+5mVI+rTyX+fwjLw6Z/1oY5GA9NY061+yPs8LL0BQYkm5r1et3lTIWGo3bJeLIZM4Dsh+VXv1Z8q7oz1PkhSwbmQH19FyQdeohgyzokidbQhGTgk8tO2ol1j2tZMPkwAh3MTRU4Gpmo641Qye69TMhBrhIb5ebmTFXt8HnRbfJT0x/hLjLdCd8hUzo27ICu7yCqZTR74RfIdBvIumSvGQJQ= branches: only: - - /.*/ + - /.*/ diff --git a/CHANGE_HISTORY.md b/CHANGE_HISTORY.md index 31154acf..3ac84267 100644 --- a/CHANGE_HISTORY.md +++ b/CHANGE_HISTORY.md @@ -1,90 +1,106 @@ -## (2024-12-27) - -- re-enable keywords now properly supported (#1031) ([83dac8a](https://github.com/cdimascio/express-openapi-validator/commit/83dac8a)), closes [#1031](https://github.com/cdimascio/express-openapi-validator/issues/1031) -- update deps ([6eb86a6](https://github.com/cdimascio/express-openapi-validator/commit/6eb86a6)) -- v5.4.2 ([c811993](https://github.com/cdimascio/express-openapi-validator/commit/c811993)) - -## (2024-12-27) - -- fixes method res with path params (#1032) ([aa60f9c](https://github.com/cdimascio/express-openapi-validator/commit/aa60f9c)), closes [#1032](https://github.com/cdimascio/express-openapi-validator/issues/1032) -- Update README.md ([d43ec2e](https://github.com/cdimascio/express-openapi-validator/commit/d43ec2e)) - -## (2024-12-26) - -- update alpha 3.1 version ([cba4aac](https://github.com/cdimascio/express-openapi-validator/commit/cba4aac)) -- v5.3.9 ([75531ae](https://github.com/cdimascio/express-openapi-validator/commit/75531ae)) -- v5.4.0 ([34359d0](https://github.com/cdimascio/express-openapi-validator/commit/34359d0)) -- feat(openapi): support OpenAPI version 3.1 (extends PR #882) (#1027) ([fc876a3](https://github.com/cdimascio/express-openapi-validator/commit/fc876a3)), closes [#882](https://github.com/cdimascio/express-openapi-validator/issues/882) [#1027](https://github.com/cdimascio/express-openapi-validator/issues/1027) [#1009](https://github.com/cdimascio/express-openapi-validator/issues/1009) [#1021](https://github.com/cdimascio/express-openapi-validator/issues/1021) [#1017](https://github.com/cdimascio/express-openapi-validator/issues/1017) [#1016](https://github.com/cdimascio/express-openapi-validator/issues/1016) -- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([8da3707](https://github.com/cdimascio/express-openapi-validator/commit/8da3707)), closes [#1021](https://github.com/cdimascio/express-openapi-validator/issues/1021) -- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([f6e6295](https://github.com/cdimascio/express-openapi-validator/commit/f6e6295)), closes [#972](https://github.com/cdimascio/express-openapi-validator/issues/972) -- fix: fix authHeader without `cookie-parser` middleware (#1003) ([17e91d5](https://github.com/cdimascio/express-openapi-validator/commit/17e91d5)), closes [#1003](https://github.com/cdimascio/express-openapi-validator/issues/1003) [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) -- fix: package.json & package-lock.json to reduce vulnerabilities (#1017) ([e88a4ef](https://github.com/cdimascio/express-openapi-validator/commit/e88a4ef)), closes [#1017](https://github.com/cdimascio/express-openapi-validator/issues/1017) -- fix: upgrade @apidevtools/json-schema-ref-parser from 11.7.0 to 11.7.2 (#1006) ([a67802b](https://github.com/cdimascio/express-openapi-validator/commit/a67802b)), closes [#1006](https://github.com/cdimascio/express-openapi-validator/issues/1006) -- fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#1001) ([7a8fcc0](https://github.com/cdimascio/express-openapi-validator/commit/7a8fcc0)), closes [#1001](https://github.com/cdimascio/express-openapi-validator/issues/1001) -- fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#1008) ([831b648](https://github.com/cdimascio/express-openapi-validator/commit/831b648)), closes [#1008](https://github.com/cdimascio/express-openapi-validator/issues/1008) -- fix: upgrade express-openapi-validator from 5.3.7 to 5.3.8 (#1011) ([65c0e56](https://github.com/cdimascio/express-openapi-validator/commit/65c0e56)), closes [#1011](https://github.com/cdimascio/express-openapi-validator/issues/1011) -- fix: upgrade path-to-regexp from 8.1.0 to 8.2.0 (#1000) ([ed6a9b7](https://github.com/cdimascio/express-openapi-validator/commit/ed6a9b7)), closes [#1000](https://github.com/cdimascio/express-openapi-validator/issues/1000) -- chore(deps): bump cookie and express in /examples/3-eov-operations (#1002) ([f2aba32](https://github.com/cdimascio/express-openapi-validator/commit/f2aba32)), closes [#1002](https://github.com/cdimascio/express-openapi-validator/issues/1002) -- chore(deps): bump path-to-regexp and express in /examples/1-standard (#1016) ([4a3efff](https://github.com/cdimascio/express-openapi-validator/commit/4a3efff)), closes [#1016](https://github.com/cdimascio/express-openapi-validator/issues/1016) - -## (2024-10-30) - -- fix: fix authHeader without `cookie-parser` middleware (#1003) ([17e91d5](https://github.com/cdimascio/express-openapi-validator/commit/17e91d5)), closes [#1003](https://github.com/cdimascio/express-openapi-validator/issues/1003) [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) -- chore(deps): bump cookie and express in /examples/3-eov-operations (#1002) ([f2aba32](https://github.com/cdimascio/express-openapi-validator/commit/f2aba32)), closes [#1002](https://github.com/cdimascio/express-openapi-validator/issues/1002) - -## (2024-10-26) - -- fix: add cookie support for HTTP bearer authentication (#949) ([00d070b](https://github.com/cdimascio/express-openapi-validator/commit/00d070b)), closes [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) -- fix: examples/1-standard/package.json & examples/1-standard/package-lock.json to reduce vulnerabilit ([8ce7fda](https://github.com/cdimascio/express-openapi-validator/commit/8ce7fda)), closes [#986](https://github.com/cdimascio/express-openapi-validator/issues/986) -- fix: examples/2-standard-multiple-api-specs/package.json & examples/2-standard-multiple-api-specs/pa ([95f5f5a](https://github.com/cdimascio/express-openapi-validator/commit/95f5f5a)), closes [#987](https://github.com/cdimascio/express-openapi-validator/issues/987) -- fix: examples/3-eov-operations/package.json & examples/3-eov-operations/package-lock.json to reduce ([e81222e](https://github.com/cdimascio/express-openapi-validator/commit/e81222e)), closes [#989](https://github.com/cdimascio/express-openapi-validator/issues/989) -- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([263c641](https://github.com/cdimascio/express-openapi-validator/commit/263c641)), closes [#994](https://github.com/cdimascio/express-openapi-validator/issues/994) -- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([e71b5fc](https://github.com/cdimascio/express-openapi-validator/commit/e71b5fc)), closes [#988](https://github.com/cdimascio/express-openapi-validator/issues/988) -- fix: package.json & package-lock.json to reduce vulnerabilities (#993) ([b6201c3](https://github.com/cdimascio/express-openapi-validator/commit/b6201c3)), closes [#993](https://github.com/cdimascio/express-openapi-validator/issues/993) -- fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#995) ([8cee5f9](https://github.com/cdimascio/express-openapi-validator/commit/8cee5f9)), closes [#995](https://github.com/cdimascio/express-openapi-validator/issues/995) -- Create SECURITY.md (#999) ([5e21e3f](https://github.com/cdimascio/express-openapi-validator/commit/5e21e3f)), closes [#999](https://github.com/cdimascio/express-openapi-validator/issues/999) -- example 6 enhancements ([789b43b](https://github.com/cdimascio/express-openapi-validator/commit/789b43b)) -- Update README.md ([946aab8](https://github.com/cdimascio/express-openapi-validator/commit/946aab8)) -- Update README.md ([f61c185](https://github.com/cdimascio/express-openapi-validator/commit/f61c185)) -- chore(deps): bump body-parser and @nestjs/platform-express (#990) ([773f18e](https://github.com/cdimascio/express-openapi-validator/commit/773f18e)), closes [#990](https://github.com/cdimascio/express-openapi-validator/issues/990) -- chore(deps): bump cookie and cookie-parser (#996) ([9bd5177](https://github.com/cdimascio/express-openapi-validator/commit/9bd5177)), closes [#996](https://github.com/cdimascio/express-openapi-validator/issues/996) -- chore(deps): bump path-to-regexp (#997) ([e60d146](https://github.com/cdimascio/express-openapi-validator/commit/e60d146)), closes [#997](https://github.com/cdimascio/express-openapi-validator/issues/997) - -## (2024-09-18) - -- fix: upgrade @types/multer from 1.4.11 to 1.4.12 (#983) ([0fa043e](https://github.com/cdimascio/express-openapi-validator/commit/0fa043e)), closes [#983](https://github.com/cdimascio/express-openapi-validator/issues/983) -- feat(path-to-regexp): path-to-regexp 8.1.0 update (#976) ([70cce65](https://github.com/cdimascio/express-openapi-validator/commit/70cce65)), closes [#976](https://github.com/cdimascio/express-openapi-validator/issues/976) - -## (2024-09-13) - -- bodyParsers is deprecated so update with expess bodyParsers (#974) ([6dc3b97](https://github.com/cdimascio/express-openapi-validator/commit/6dc3b97)), closes [#974](https://github.com/cdimascio/express-openapi-validator/issues/974) -- Update README.md ([772d1dc](https://github.com/cdimascio/express-openapi-validator/commit/772d1dc)) -- Update README.md ([de4219e](https://github.com/cdimascio/express-openapi-validator/commit/de4219e)) -- fix: upgrade express-openapi-validator from 5.2.0 to 5.3.1 (#960) ([bd636bb](https://github.com/cdimascio/express-openapi-validator/commit/bd636bb)), closes [#960](https://github.com/cdimascio/express-openapi-validator/issues/960) -- chore(deps-dev): bump braces from 3.0.2 to 3.0.3 in /examples/9-nestjs (#964) ([148fa90](https://github.com/cdimascio/express-openapi-validator/commit/148fa90)), closes [#964](https://github.com/cdimascio/express-openapi-validator/issues/964) -- chore(deps-dev): bump braces in /examples/7-response-date-serialization (#963) ([aa3018a](https://github.com/cdimascio/express-openapi-validator/commit/aa3018a)), closes [#963](https://github.com/cdimascio/express-openapi-validator/issues/963) - -## (2024-09-06) - -- fix: Dereference path parameters (#962) ([0aebe5d](https://github.com/cdimascio/express-openapi-validator/commit/0aebe5d)), closes [#962](https://github.com/cdimascio/express-openapi-validator/issues/962) -- fix: upgrade express-openapi-validator from 5.2.0 to 5.3.1 (#951) ([5b0058d](https://github.com/cdimascio/express-openapi-validator/commit/5b0058d)), closes [#951](https://github.com/cdimascio/express-openapi-validator/issues/951) -- [StepSecurity] ci: Harden GitHub Actions (#959) ([78e55be](https://github.com/cdimascio/express-openapi-validator/commit/78e55be)), closes [#959](https://github.com/cdimascio/express-openapi-validator/issues/959) -- Fix changelog breaking changes notice (#961) ([0a8dc2f](https://github.com/cdimascio/express-openapi-validator/commit/0a8dc2f)), closes [#961](https://github.com/cdimascio/express-openapi-validator/issues/961) -- update README ([7334ccd](https://github.com/cdimascio/express-openapi-validator/commit/7334ccd)) -- chore(deps-dev): bump braces in /examples/5-custom-operation-resolver (#958) ([eda5612](https://github.com/cdimascio/express-openapi-validator/commit/eda5612)), closes [#958](https://github.com/cdimascio/express-openapi-validator/issues/958) -- chore(deps): bump braces in /examples/4-eov-operations-babel (#957) ([749a8c8](https://github.com/cdimascio/express-openapi-validator/commit/749a8c8)), closes [#957](https://github.com/cdimascio/express-openapi-validator/issues/957) -- chore(deps): bump webpack and @nestjs/cli in /examples/9-nestjs (#953) ([299aad6](https://github.com/cdimascio/express-openapi-validator/commit/299aad6)), closes [#953](https://github.com/cdimascio/express-openapi-validator/issues/953) - -## (2024-08-31) - -- Change AJV allErrors default and support user setting (#955) ([392f1dd](https://github.com/cdimascio/express-openapi-validator/commit/392f1dd)), closes [#955](https://github.com/cdimascio/express-openapi-validator/issues/955) [#954](https://github.com/cdimascio/express-openapi-validator/issues/954) -- Update README.md ([f20b1c9](https://github.com/cdimascio/express-openapi-validator/commit/f20b1c9)) -- Use lenient resolver type (#956) ([826ba62](https://github.com/cdimascio/express-openapi-validator/commit/826ba62)), closes [#956](https://github.com/cdimascio/express-openapi-validator/issues/956) [#921](https://github.com/cdimascio/express-openapi-validator/issues/921) [#952](https://github.com/cdimascio/express-openapi-validator/issues/952) +## (2024-12-27) + +* re-enable keywords now properly supported (#1031) ([83dac8a](https://github.com/cdimascio/express-openapi-validator/commit/83dac8a)), closes [#1031](https://github.com/cdimascio/express-openapi-validator/issues/1031) +* update deps ([6eb86a6](https://github.com/cdimascio/express-openapi-validator/commit/6eb86a6)) +* v5.4.2 ([c811993](https://github.com/cdimascio/express-openapi-validator/commit/c811993)) + + + +## (2024-12-27) + +* fixes method res with path params (#1032) ([aa60f9c](https://github.com/cdimascio/express-openapi-validator/commit/aa60f9c)), closes [#1032](https://github.com/cdimascio/express-openapi-validator/issues/1032) +* Update README.md ([d43ec2e](https://github.com/cdimascio/express-openapi-validator/commit/d43ec2e)) + + + +## (2024-12-26) + +* update alpha 3.1 version ([cba4aac](https://github.com/cdimascio/express-openapi-validator/commit/cba4aac)) +* v5.3.9 ([75531ae](https://github.com/cdimascio/express-openapi-validator/commit/75531ae)) +* v5.4.0 ([34359d0](https://github.com/cdimascio/express-openapi-validator/commit/34359d0)) +* feat(openapi): support OpenAPI version 3.1 (extends PR #882) (#1027) ([fc876a3](https://github.com/cdimascio/express-openapi-validator/commit/fc876a3)), closes [#882](https://github.com/cdimascio/express-openapi-validator/issues/882) [#1027](https://github.com/cdimascio/express-openapi-validator/issues/1027) [#1009](https://github.com/cdimascio/express-openapi-validator/issues/1009) [#1021](https://github.com/cdimascio/express-openapi-validator/issues/1021) [#1017](https://github.com/cdimascio/express-openapi-validator/issues/1017) [#1016](https://github.com/cdimascio/express-openapi-validator/issues/1016) +* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([8da3707](https://github.com/cdimascio/express-openapi-validator/commit/8da3707)), closes [#1021](https://github.com/cdimascio/express-openapi-validator/issues/1021) +* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([f6e6295](https://github.com/cdimascio/express-openapi-validator/commit/f6e6295)), closes [#972](https://github.com/cdimascio/express-openapi-validator/issues/972) +* fix: fix authHeader without `cookie-parser` middleware (#1003) ([17e91d5](https://github.com/cdimascio/express-openapi-validator/commit/17e91d5)), closes [#1003](https://github.com/cdimascio/express-openapi-validator/issues/1003) [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) +* fix: package.json & package-lock.json to reduce vulnerabilities (#1017) ([e88a4ef](https://github.com/cdimascio/express-openapi-validator/commit/e88a4ef)), closes [#1017](https://github.com/cdimascio/express-openapi-validator/issues/1017) +* fix: upgrade @apidevtools/json-schema-ref-parser from 11.7.0 to 11.7.2 (#1006) ([a67802b](https://github.com/cdimascio/express-openapi-validator/commit/a67802b)), closes [#1006](https://github.com/cdimascio/express-openapi-validator/issues/1006) +* fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#1001) ([7a8fcc0](https://github.com/cdimascio/express-openapi-validator/commit/7a8fcc0)), closes [#1001](https://github.com/cdimascio/express-openapi-validator/issues/1001) +* fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#1008) ([831b648](https://github.com/cdimascio/express-openapi-validator/commit/831b648)), closes [#1008](https://github.com/cdimascio/express-openapi-validator/issues/1008) +* fix: upgrade express-openapi-validator from 5.3.7 to 5.3.8 (#1011) ([65c0e56](https://github.com/cdimascio/express-openapi-validator/commit/65c0e56)), closes [#1011](https://github.com/cdimascio/express-openapi-validator/issues/1011) +* fix: upgrade path-to-regexp from 8.1.0 to 8.2.0 (#1000) ([ed6a9b7](https://github.com/cdimascio/express-openapi-validator/commit/ed6a9b7)), closes [#1000](https://github.com/cdimascio/express-openapi-validator/issues/1000) +* chore(deps): bump cookie and express in /examples/3-eov-operations (#1002) ([f2aba32](https://github.com/cdimascio/express-openapi-validator/commit/f2aba32)), closes [#1002](https://github.com/cdimascio/express-openapi-validator/issues/1002) +* chore(deps): bump path-to-regexp and express in /examples/1-standard (#1016) ([4a3efff](https://github.com/cdimascio/express-openapi-validator/commit/4a3efff)), closes [#1016](https://github.com/cdimascio/express-openapi-validator/issues/1016) + + + +## (2024-10-30) + +* fix: fix authHeader without `cookie-parser` middleware (#1003) ([17e91d5](https://github.com/cdimascio/express-openapi-validator/commit/17e91d5)), closes [#1003](https://github.com/cdimascio/express-openapi-validator/issues/1003) [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) +* chore(deps): bump cookie and express in /examples/3-eov-operations (#1002) ([f2aba32](https://github.com/cdimascio/express-openapi-validator/commit/f2aba32)), closes [#1002](https://github.com/cdimascio/express-openapi-validator/issues/1002) + + + +## (2024-10-26) + +* fix: add cookie support for HTTP bearer authentication (#949) ([00d070b](https://github.com/cdimascio/express-openapi-validator/commit/00d070b)), closes [#949](https://github.com/cdimascio/express-openapi-validator/issues/949) +* fix: examples/1-standard/package.json & examples/1-standard/package-lock.json to reduce vulnerabilit ([8ce7fda](https://github.com/cdimascio/express-openapi-validator/commit/8ce7fda)), closes [#986](https://github.com/cdimascio/express-openapi-validator/issues/986) +* fix: examples/2-standard-multiple-api-specs/package.json & examples/2-standard-multiple-api-specs/pa ([95f5f5a](https://github.com/cdimascio/express-openapi-validator/commit/95f5f5a)), closes [#987](https://github.com/cdimascio/express-openapi-validator/issues/987) +* fix: examples/3-eov-operations/package.json & examples/3-eov-operations/package-lock.json to reduce ([e81222e](https://github.com/cdimascio/express-openapi-validator/commit/e81222e)), closes [#989](https://github.com/cdimascio/express-openapi-validator/issues/989) +* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([263c641](https://github.com/cdimascio/express-openapi-validator/commit/263c641)), closes [#994](https://github.com/cdimascio/express-openapi-validator/issues/994) +* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([e71b5fc](https://github.com/cdimascio/express-openapi-validator/commit/e71b5fc)), closes [#988](https://github.com/cdimascio/express-openapi-validator/issues/988) +* fix: package.json & package-lock.json to reduce vulnerabilities (#993) ([b6201c3](https://github.com/cdimascio/express-openapi-validator/commit/b6201c3)), closes [#993](https://github.com/cdimascio/express-openapi-validator/issues/993) +* fix: upgrade express-openapi-validator from 5.3.6 to 5.3.7 (#995) ([8cee5f9](https://github.com/cdimascio/express-openapi-validator/commit/8cee5f9)), closes [#995](https://github.com/cdimascio/express-openapi-validator/issues/995) +* Create SECURITY.md (#999) ([5e21e3f](https://github.com/cdimascio/express-openapi-validator/commit/5e21e3f)), closes [#999](https://github.com/cdimascio/express-openapi-validator/issues/999) +* example 6 enhancements ([789b43b](https://github.com/cdimascio/express-openapi-validator/commit/789b43b)) +* Update README.md ([946aab8](https://github.com/cdimascio/express-openapi-validator/commit/946aab8)) +* Update README.md ([f61c185](https://github.com/cdimascio/express-openapi-validator/commit/f61c185)) +* chore(deps): bump body-parser and @nestjs/platform-express (#990) ([773f18e](https://github.com/cdimascio/express-openapi-validator/commit/773f18e)), closes [#990](https://github.com/cdimascio/express-openapi-validator/issues/990) +* chore(deps): bump cookie and cookie-parser (#996) ([9bd5177](https://github.com/cdimascio/express-openapi-validator/commit/9bd5177)), closes [#996](https://github.com/cdimascio/express-openapi-validator/issues/996) +* chore(deps): bump path-to-regexp (#997) ([e60d146](https://github.com/cdimascio/express-openapi-validator/commit/e60d146)), closes [#997](https://github.com/cdimascio/express-openapi-validator/issues/997) + + + +## (2024-09-18) + +* fix: upgrade @types/multer from 1.4.11 to 1.4.12 (#983) ([0fa043e](https://github.com/cdimascio/express-openapi-validator/commit/0fa043e)), closes [#983](https://github.com/cdimascio/express-openapi-validator/issues/983) +* feat(path-to-regexp): path-to-regexp 8.1.0 update (#976) ([70cce65](https://github.com/cdimascio/express-openapi-validator/commit/70cce65)), closes [#976](https://github.com/cdimascio/express-openapi-validator/issues/976) + + + +## (2024-09-13) + +* bodyParsers is deprecated so update with expess bodyParsers (#974) ([6dc3b97](https://github.com/cdimascio/express-openapi-validator/commit/6dc3b97)), closes [#974](https://github.com/cdimascio/express-openapi-validator/issues/974) +* Update README.md ([772d1dc](https://github.com/cdimascio/express-openapi-validator/commit/772d1dc)) +* Update README.md ([de4219e](https://github.com/cdimascio/express-openapi-validator/commit/de4219e)) +* fix: upgrade express-openapi-validator from 5.2.0 to 5.3.1 (#960) ([bd636bb](https://github.com/cdimascio/express-openapi-validator/commit/bd636bb)), closes [#960](https://github.com/cdimascio/express-openapi-validator/issues/960) +* chore(deps-dev): bump braces from 3.0.2 to 3.0.3 in /examples/9-nestjs (#964) ([148fa90](https://github.com/cdimascio/express-openapi-validator/commit/148fa90)), closes [#964](https://github.com/cdimascio/express-openapi-validator/issues/964) +* chore(deps-dev): bump braces in /examples/7-response-date-serialization (#963) ([aa3018a](https://github.com/cdimascio/express-openapi-validator/commit/aa3018a)), closes [#963](https://github.com/cdimascio/express-openapi-validator/issues/963) + + + +## (2024-09-06) + +* fix: Dereference path parameters (#962) ([0aebe5d](https://github.com/cdimascio/express-openapi-validator/commit/0aebe5d)), closes [#962](https://github.com/cdimascio/express-openapi-validator/issues/962) +* fix: upgrade express-openapi-validator from 5.2.0 to 5.3.1 (#951) ([5b0058d](https://github.com/cdimascio/express-openapi-validator/commit/5b0058d)), closes [#951](https://github.com/cdimascio/express-openapi-validator/issues/951) +* [StepSecurity] ci: Harden GitHub Actions (#959) ([78e55be](https://github.com/cdimascio/express-openapi-validator/commit/78e55be)), closes [#959](https://github.com/cdimascio/express-openapi-validator/issues/959) +* Fix changelog breaking changes notice (#961) ([0a8dc2f](https://github.com/cdimascio/express-openapi-validator/commit/0a8dc2f)), closes [#961](https://github.com/cdimascio/express-openapi-validator/issues/961) +* update README ([7334ccd](https://github.com/cdimascio/express-openapi-validator/commit/7334ccd)) +* chore(deps-dev): bump braces in /examples/5-custom-operation-resolver (#958) ([eda5612](https://github.com/cdimascio/express-openapi-validator/commit/eda5612)), closes [#958](https://github.com/cdimascio/express-openapi-validator/issues/958) +* chore(deps): bump braces in /examples/4-eov-operations-babel (#957) ([749a8c8](https://github.com/cdimascio/express-openapi-validator/commit/749a8c8)), closes [#957](https://github.com/cdimascio/express-openapi-validator/issues/957) +* chore(deps): bump webpack and @nestjs/cli in /examples/9-nestjs (#953) ([299aad6](https://github.com/cdimascio/express-openapi-validator/commit/299aad6)), closes [#953](https://github.com/cdimascio/express-openapi-validator/issues/953) + + + +## (2024-08-31) + +* Change AJV allErrors default and support user setting (#955) ([392f1dd](https://github.com/cdimascio/express-openapi-validator/commit/392f1dd)), closes [#955](https://github.com/cdimascio/express-openapi-validator/issues/955) [#954](https://github.com/cdimascio/express-openapi-validator/issues/954) +* Update README.md ([f20b1c9](https://github.com/cdimascio/express-openapi-validator/commit/f20b1c9)) +* Use lenient resolver type (#956) ([826ba62](https://github.com/cdimascio/express-openapi-validator/commit/826ba62)), closes [#956](https://github.com/cdimascio/express-openapi-validator/issues/956) [#921](https://github.com/cdimascio/express-openapi-validator/issues/921) [#952](https://github.com/cdimascio/express-openapi-validator/issues/952) + ### breaking change By default, request and response validation now stops after the first failure. Only one error will be reported even when multiple may exist. This follows best practices from AJV: - - [Security risks of trusted schemas](https://ajv.js.org/security.html#security-risks-of-trusted-schemas) - [`allErrors` option](https://ajv.js.org/options.html#allerrors) @@ -100,211 +116,251 @@ app.use( validateResponses: { allErrors: true, }, - }), + }) ); ``` -## (2024-08-24) - -- chore(deps-dev): bump @babel/traverse in /examples/9-nestjs (#948) ([edd054f](https://github.com/cdimascio/express-openapi-validator/commit/edd054f)), closes [#948](https://github.com/cdimascio/express-openapi-validator/issues/948) -- chore(deps-dev): bump braces in /examples/8-top-level-discriminator (#929) ([e3a9526](https://github.com/cdimascio/express-openapi-validator/commit/e3a9526)), closes [#929](https://github.com/cdimascio/express-openapi-validator/issues/929) -- chore(deps-dev): bump ws from 7.5.5 to 7.5.10 in /examples/9-nestjs (#930) ([9d5895b](https://github.com/cdimascio/express-openapi-validator/commit/9d5895b)), closes [#930](https://github.com/cdimascio/express-openapi-validator/issues/930) -- fix: correct security schema logic for OR verification (#946) ([2265a10](https://github.com/cdimascio/express-openapi-validator/commit/2265a10)), closes [#946](https://github.com/cdimascio/express-openapi-validator/issues/946) -- fix: upgrade @apidevtools/json-schema-ref-parser from 11.6.4 to 11.7.0 (#947) ([ea4129c](https://github.com/cdimascio/express-openapi-validator/commit/ea4129c)), closes [#947](https://github.com/cdimascio/express-openapi-validator/issues/947) -- fix: upgrade ajv from 8.15.0 to 8.17.1 (#945) ([087d8f7](https://github.com/cdimascio/express-openapi-validator/commit/087d8f7)), closes [#945](https://github.com/cdimascio/express-openapi-validator/issues/945) -- fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#944) ([f022d21](https://github.com/cdimascio/express-openapi-validator/commit/f022d21)), closes [#944](https://github.com/cdimascio/express-openapi-validator/issues/944) -- version 5.3.2 ([4428922](https://github.com/cdimascio/express-openapi-validator/commit/4428922)) - -## (2024-08-24) - -- fix: correct security schema logic for OR verification (#946) ([2265a10](https://github.com/cdimascio/express-openapi-validator/commit/2265a10)), closes [#946](https://github.com/cdimascio/express-openapi-validator/issues/946) -- fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#944) ([f022d21](https://github.com/cdimascio/express-openapi-validator/commit/f022d21)), closes [#944](https://github.com/cdimascio/express-openapi-validator/issues/944) - -## (2024-08-05) - -- Stripped query params for req.url branch arm (#942) ([26d06c4](https://github.com/cdimascio/express-openapi-validator/commit/26d06c4)), closes [#942](https://github.com/cdimascio/express-openapi-validator/issues/942) -- Update LICENSE ([20727ff](https://github.com/cdimascio/express-openapi-validator/commit/20727ff)) -- version 5.2.1 ([aace73c](https://github.com/cdimascio/express-openapi-validator/commit/aace73c)) -- FIX: issue #917 (#935) ([8e66d3f](https://github.com/cdimascio/express-openapi-validator/commit/8e66d3f)), closes [#917](https://github.com/cdimascio/express-openapi-validator/issues/917) [#935](https://github.com/cdimascio/express-openapi-validator/issues/935) -- fix: upgrade @apidevtools/json-schema-ref-parser from 11.6.2 to 11.6.4 (#937) ([f148eeb](https://github.com/cdimascio/express-openapi-validator/commit/f148eeb)), closes [#937](https://github.com/cdimascio/express-openapi-validator/issues/937) -- fix: upgrade ajv from 8.14.0 to 8.15.0 (#938) ([a1ea81f](https://github.com/cdimascio/express-openapi-validator/commit/a1ea81f)), closes [#938](https://github.com/cdimascio/express-openapi-validator/issues/938) -- fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#936) ([2d75db4](https://github.com/cdimascio/express-openapi-validator/commit/2d75db4)), closes [#936](https://github.com/cdimascio/express-openapi-validator/issues/936) -- chore(deps-dev): bump braces from 3.0.2 to 3.0.3 (#928) ([093bd3c](https://github.com/cdimascio/express-openapi-validator/commit/093bd3c)), closes [#928](https://github.com/cdimascio/express-openapi-validator/issues/928) - -## (2024-06-02) - -- Add `express` as peer dependency (#907) ([4e8bc84](https://github.com/cdimascio/express-openapi-validator/commit/4e8bc84)), closes [#907](https://github.com/cdimascio/express-openapi-validator/issues/907) -- Add multipart fix when does not exist any body (#905) ([5c98d17](https://github.com/cdimascio/express-openapi-validator/commit/5c98d17)), closes [#905](https://github.com/cdimascio/express-openapi-validator/issues/905) -- add reponse serializer tests for arrays ([bbbd160](https://github.com/cdimascio/express-openapi-validator/commit/bbbd160)) -- pass coerceTypes through (#809) ([8f7c678](https://github.com/cdimascio/express-openapi-validator/commit/8f7c678)), closes [#809](https://github.com/cdimascio/express-openapi-validator/issues/809) -- Support async operation handler resolver (#921) ([a4a7175](https://github.com/cdimascio/express-openapi-validator/commit/a4a7175)), closes [#921](https://github.com/cdimascio/express-openapi-validator/issues/921) -- upgrade ajv ([a708132](https://github.com/cdimascio/express-openapi-validator/commit/a708132)) -- upgrade example 3 ([43cccc8](https://github.com/cdimascio/express-openapi-validator/commit/43cccc8)) -- upgrade example 4 ([255f20f](https://github.com/cdimascio/express-openapi-validator/commit/255f20f)) -- v5.2.0 ([42cb3ab](https://github.com/cdimascio/express-openapi-validator/commit/42cb3ab)) -- chore: apiSpec may be const literal (#854) ([e35a07c](https://github.com/cdimascio/express-openapi-validator/commit/e35a07c)), closes [#854](https://github.com/cdimascio/express-openapi-validator/issues/854) -- chore(dependencies): bump @apidevtools/json-schema-ref-parser to 11.6.2 to prevent vulnerability (#9 ([61ff0cf](https://github.com/cdimascio/express-openapi-validator/commit/61ff0cf)), closes [#918](https://github.com/cdimascio/express-openapi-validator/issues/918) -- chore(deps-dev): bump @babel/traverse (#924) ([5a04ea9](https://github.com/cdimascio/express-openapi-validator/commit/5a04ea9)), closes [#924](https://github.com/cdimascio/express-openapi-validator/issues/924) -- chore(deps): bump axios, @nestjs/common, @nestjs/core, @nestjs/platform-express and @nestjs/testing ([b77150f](https://github.com/cdimascio/express-openapi-validator/commit/b77150f)), closes [#925](https://github.com/cdimascio/express-openapi-validator/issues/925) -- chore(deps): bump webpack and @nestjs/cli in /examples/9-nestjs (#831) ([c0c5f4c](https://github.com/cdimascio/express-openapi-validator/commit/c0c5f4c)), closes [#831](https://github.com/cdimascio/express-openapi-validator/issues/831) -- fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([87d173b](https://github.com/cdimascio/express-openapi-validator/commit/87d173b)), closes [#911](https://github.com/cdimascio/express-openapi-validator/issues/911) -- fix: package.json & package-lock.json to reduce vulnerabilities (#920) ([898ceb7](https://github.com/cdimascio/express-openapi-validator/commit/898ceb7)), closes [#920](https://github.com/cdimascio/express-openapi-validator/issues/920) -- fix: upgrade @types/multer from 1.4.7 to 1.4.11 (#897) ([a7d67e7](https://github.com/cdimascio/express-openapi-validator/commit/a7d67e7)), closes [#897](https://github.com/cdimascio/express-openapi-validator/issues/897) -- fix: upgrade path-to-regexp from 6.2.0 to 6.2.2 (#914) ([bce2d6a](https://github.com/cdimascio/express-openapi-validator/commit/bce2d6a)), closes [#914](https://github.com/cdimascio/express-openapi-validator/issues/914) + +## (2024-08-24) + +* chore(deps-dev): bump @babel/traverse in /examples/9-nestjs (#948) ([edd054f](https://github.com/cdimascio/express-openapi-validator/commit/edd054f)), closes [#948](https://github.com/cdimascio/express-openapi-validator/issues/948) +* chore(deps-dev): bump braces in /examples/8-top-level-discriminator (#929) ([e3a9526](https://github.com/cdimascio/express-openapi-validator/commit/e3a9526)), closes [#929](https://github.com/cdimascio/express-openapi-validator/issues/929) +* chore(deps-dev): bump ws from 7.5.5 to 7.5.10 in /examples/9-nestjs (#930) ([9d5895b](https://github.com/cdimascio/express-openapi-validator/commit/9d5895b)), closes [#930](https://github.com/cdimascio/express-openapi-validator/issues/930) +* fix: correct security schema logic for OR verification (#946) ([2265a10](https://github.com/cdimascio/express-openapi-validator/commit/2265a10)), closes [#946](https://github.com/cdimascio/express-openapi-validator/issues/946) +* fix: upgrade @apidevtools/json-schema-ref-parser from 11.6.4 to 11.7.0 (#947) ([ea4129c](https://github.com/cdimascio/express-openapi-validator/commit/ea4129c)), closes [#947](https://github.com/cdimascio/express-openapi-validator/issues/947) +* fix: upgrade ajv from 8.15.0 to 8.17.1 (#945) ([087d8f7](https://github.com/cdimascio/express-openapi-validator/commit/087d8f7)), closes [#945](https://github.com/cdimascio/express-openapi-validator/issues/945) +* fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#944) ([f022d21](https://github.com/cdimascio/express-openapi-validator/commit/f022d21)), closes [#944](https://github.com/cdimascio/express-openapi-validator/issues/944) +* version 5.3.2 ([4428922](https://github.com/cdimascio/express-openapi-validator/commit/4428922)) + + + +## (2024-08-24) + +* fix: correct security schema logic for OR verification (#946) ([2265a10](https://github.com/cdimascio/express-openapi-validator/commit/2265a10)), closes [#946](https://github.com/cdimascio/express-openapi-validator/issues/946) +* fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#944) ([f022d21](https://github.com/cdimascio/express-openapi-validator/commit/f022d21)), closes [#944](https://github.com/cdimascio/express-openapi-validator/issues/944) + + + +## (2024-08-05) + +* Stripped query params for req.url branch arm (#942) ([26d06c4](https://github.com/cdimascio/express-openapi-validator/commit/26d06c4)), closes [#942](https://github.com/cdimascio/express-openapi-validator/issues/942) +* Update LICENSE ([20727ff](https://github.com/cdimascio/express-openapi-validator/commit/20727ff)) +* version 5.2.1 ([aace73c](https://github.com/cdimascio/express-openapi-validator/commit/aace73c)) +* FIX: issue #917 (#935) ([8e66d3f](https://github.com/cdimascio/express-openapi-validator/commit/8e66d3f)), closes [#917](https://github.com/cdimascio/express-openapi-validator/issues/917) [#935](https://github.com/cdimascio/express-openapi-validator/issues/935) +* fix: upgrade @apidevtools/json-schema-ref-parser from 11.6.2 to 11.6.4 (#937) ([f148eeb](https://github.com/cdimascio/express-openapi-validator/commit/f148eeb)), closes [#937](https://github.com/cdimascio/express-openapi-validator/issues/937) +* fix: upgrade ajv from 8.14.0 to 8.15.0 (#938) ([a1ea81f](https://github.com/cdimascio/express-openapi-validator/commit/a1ea81f)), closes [#938](https://github.com/cdimascio/express-openapi-validator/issues/938) +* fix: upgrade express-openapi-validator from 5.1.6 to 5.2.0 (#936) ([2d75db4](https://github.com/cdimascio/express-openapi-validator/commit/2d75db4)), closes [#936](https://github.com/cdimascio/express-openapi-validator/issues/936) +* chore(deps-dev): bump braces from 3.0.2 to 3.0.3 (#928) ([093bd3c](https://github.com/cdimascio/express-openapi-validator/commit/093bd3c)), closes [#928](https://github.com/cdimascio/express-openapi-validator/issues/928) + + + +## (2024-06-02) + +* Add `express` as peer dependency (#907) ([4e8bc84](https://github.com/cdimascio/express-openapi-validator/commit/4e8bc84)), closes [#907](https://github.com/cdimascio/express-openapi-validator/issues/907) +* Add multipart fix when does not exist any body (#905) ([5c98d17](https://github.com/cdimascio/express-openapi-validator/commit/5c98d17)), closes [#905](https://github.com/cdimascio/express-openapi-validator/issues/905) +* add reponse serializer tests for arrays ([bbbd160](https://github.com/cdimascio/express-openapi-validator/commit/bbbd160)) +* pass coerceTypes through (#809) ([8f7c678](https://github.com/cdimascio/express-openapi-validator/commit/8f7c678)), closes [#809](https://github.com/cdimascio/express-openapi-validator/issues/809) +* Support async operation handler resolver (#921) ([a4a7175](https://github.com/cdimascio/express-openapi-validator/commit/a4a7175)), closes [#921](https://github.com/cdimascio/express-openapi-validator/issues/921) +* upgrade ajv ([a708132](https://github.com/cdimascio/express-openapi-validator/commit/a708132)) +* upgrade example 3 ([43cccc8](https://github.com/cdimascio/express-openapi-validator/commit/43cccc8)) +* upgrade example 4 ([255f20f](https://github.com/cdimascio/express-openapi-validator/commit/255f20f)) +* v5.2.0 ([42cb3ab](https://github.com/cdimascio/express-openapi-validator/commit/42cb3ab)) +* chore: apiSpec may be const literal (#854) ([e35a07c](https://github.com/cdimascio/express-openapi-validator/commit/e35a07c)), closes [#854](https://github.com/cdimascio/express-openapi-validator/issues/854) +* chore(dependencies): bump @apidevtools/json-schema-ref-parser to 11.6.2 to prevent vulnerability (#9 ([61ff0cf](https://github.com/cdimascio/express-openapi-validator/commit/61ff0cf)), closes [#918](https://github.com/cdimascio/express-openapi-validator/issues/918) +* chore(deps-dev): bump @babel/traverse (#924) ([5a04ea9](https://github.com/cdimascio/express-openapi-validator/commit/5a04ea9)), closes [#924](https://github.com/cdimascio/express-openapi-validator/issues/924) +* chore(deps): bump axios, @nestjs/common, @nestjs/core, @nestjs/platform-express and @nestjs/testing ([b77150f](https://github.com/cdimascio/express-openapi-validator/commit/b77150f)), closes [#925](https://github.com/cdimascio/express-openapi-validator/issues/925) +* chore(deps): bump webpack and @nestjs/cli in /examples/9-nestjs (#831) ([c0c5f4c](https://github.com/cdimascio/express-openapi-validator/commit/c0c5f4c)), closes [#831](https://github.com/cdimascio/express-openapi-validator/issues/831) +* fix: examples/4-eov-operations-babel/package.json & examples/4-eov-operations-babel/package-lock.jso ([87d173b](https://github.com/cdimascio/express-openapi-validator/commit/87d173b)), closes [#911](https://github.com/cdimascio/express-openapi-validator/issues/911) +* fix: package.json & package-lock.json to reduce vulnerabilities (#920) ([898ceb7](https://github.com/cdimascio/express-openapi-validator/commit/898ceb7)), closes [#920](https://github.com/cdimascio/express-openapi-validator/issues/920) +* fix: upgrade @types/multer from 1.4.7 to 1.4.11 (#897) ([a7d67e7](https://github.com/cdimascio/express-openapi-validator/commit/a7d67e7)), closes [#897](https://github.com/cdimascio/express-openapi-validator/issues/897) +* fix: upgrade path-to-regexp from 6.2.0 to 6.2.2 (#914) ([bce2d6a](https://github.com/cdimascio/express-openapi-validator/commit/bce2d6a)), closes [#914](https://github.com/cdimascio/express-openapi-validator/issues/914) + + ## 5.1.6 (2024-02-11) -- Fixes for 881 - multiple specs w/validateRequests fail (#903) ([766806b](https://github.com/cdimascio/express-openapi-validator/commit/766806b)), closes [#903](https://github.com/cdimascio/express-openapi-validator/issues/903) +* Fixes for 881 - multiple specs w/validateRequests fail (#903) ([766806b](https://github.com/cdimascio/express-openapi-validator/commit/766806b)), closes [#903](https://github.com/cdimascio/express-openapi-validator/issues/903) + + ## 5.1.5 (2024-02-10) -- fixes write-only tests ([8c53e58](https://github.com/cdimascio/express-openapi-validator/commit/8c53e58)) -- Support writeOnly + required combination #149 (#756) ([4f16ed2](https://github.com/cdimascio/express-openapi-validator/commit/4f16ed2)), closes [#149](https://github.com/cdimascio/express-openapi-validator/issues/149) [#756](https://github.com/cdimascio/express-openapi-validator/issues/756) -- v5.1.5 ([708f2f5](https://github.com/cdimascio/express-openapi-validator/commit/708f2f5)) +* fixes write-only tests ([8c53e58](https://github.com/cdimascio/express-openapi-validator/commit/8c53e58)) +* Support writeOnly + required combination #149 (#756) ([4f16ed2](https://github.com/cdimascio/express-openapi-validator/commit/4f16ed2)), closes [#149](https://github.com/cdimascio/express-openapi-validator/issues/149) [#756](https://github.com/cdimascio/express-openapi-validator/issues/756) +* v5.1.5 ([708f2f5](https://github.com/cdimascio/express-openapi-validator/commit/708f2f5)) + + ## 5.1.4 (2024-02-09) -- add cookies to examples 1 and 2 (#891) ([2c95d5b](https://github.com/cdimascio/express-openapi-validator/commit/2c95d5b)), closes [#891](https://github.com/cdimascio/express-openapi-validator/issues/891) -- Direct example broken link to the guide ([00a9c8f](https://github.com/cdimascio/express-openapi-validator/commit/00a9c8f)) -- fixes badging for build and test ([631fb7b](https://github.com/cdimascio/express-openapi-validator/commit/631fb7b)) -- npm audit fix (#892) ([2977c0a](https://github.com/cdimascio/express-openapi-validator/commit/2977c0a)), closes [#892](https://github.com/cdimascio/express-openapi-validator/issues/892) -- Remove read only and write only fields (#895) ([97617fd](https://github.com/cdimascio/express-openapi-validator/commit/97617fd)), closes [#895](https://github.com/cdimascio/express-openapi-validator/issues/895) [#627](https://github.com/cdimascio/express-openapi-validator/issues/627) -- removes lodash.uniq and lodash.zipobject dependencies (#893) ([1206802](https://github.com/cdimascio/express-openapi-validator/commit/1206802)), closes [#893](https://github.com/cdimascio/express-openapi-validator/issues/893) -- Update CONTRIBUTING.md ([6d67169](https://github.com/cdimascio/express-openapi-validator/commit/6d67169)) -- Update README.md ([dffda28](https://github.com/cdimascio/express-openapi-validator/commit/dffda28)) -- Update README.md ([bdd0d79](https://github.com/cdimascio/express-openapi-validator/commit/bdd0d79)) -- Update README.md (#896) ([bb66916](https://github.com/cdimascio/express-openapi-validator/commit/bb66916)), closes [#896](https://github.com/cdimascio/express-openapi-validator/issues/896) -- v5.1.4 ([b3d7483](https://github.com/cdimascio/express-openapi-validator/commit/b3d7483)) -- v5.1.4 ([509fa22](https://github.com/cdimascio/express-openapi-validator/commit/509fa22)) -- fix: #887 allow multiple params with wildcard (#898) ([2d33d0a](https://github.com/cdimascio/express-openapi-validator/commit/2d33d0a)), closes [#887](https://github.com/cdimascio/express-openapi-validator/issues/887) [#898](https://github.com/cdimascio/express-openapi-validator/issues/898) [#1](https://github.com/cdimascio/express-openapi-validator/issues/1) -- docs: fix doc typo in README.md (#885) ([8a81bf8](https://github.com/cdimascio/express-openapi-validator/commit/8a81bf8)), closes [#885](https://github.com/cdimascio/express-openapi-validator/issues/885) +* add cookies to examples 1 and 2 (#891) ([2c95d5b](https://github.com/cdimascio/express-openapi-validator/commit/2c95d5b)), closes [#891](https://github.com/cdimascio/express-openapi-validator/issues/891) +* Direct example broken link to the guide ([00a9c8f](https://github.com/cdimascio/express-openapi-validator/commit/00a9c8f)) +* fixes badging for build and test ([631fb7b](https://github.com/cdimascio/express-openapi-validator/commit/631fb7b)) +* npm audit fix (#892) ([2977c0a](https://github.com/cdimascio/express-openapi-validator/commit/2977c0a)), closes [#892](https://github.com/cdimascio/express-openapi-validator/issues/892) +* Remove read only and write only fields (#895) ([97617fd](https://github.com/cdimascio/express-openapi-validator/commit/97617fd)), closes [#895](https://github.com/cdimascio/express-openapi-validator/issues/895) [#627](https://github.com/cdimascio/express-openapi-validator/issues/627) +* removes lodash.uniq and lodash.zipobject dependencies (#893) ([1206802](https://github.com/cdimascio/express-openapi-validator/commit/1206802)), closes [#893](https://github.com/cdimascio/express-openapi-validator/issues/893) +* Update CONTRIBUTING.md ([6d67169](https://github.com/cdimascio/express-openapi-validator/commit/6d67169)) +* Update README.md ([dffda28](https://github.com/cdimascio/express-openapi-validator/commit/dffda28)) +* Update README.md ([bdd0d79](https://github.com/cdimascio/express-openapi-validator/commit/bdd0d79)) +* Update README.md (#896) ([bb66916](https://github.com/cdimascio/express-openapi-validator/commit/bb66916)), closes [#896](https://github.com/cdimascio/express-openapi-validator/issues/896) +* v5.1.4 ([b3d7483](https://github.com/cdimascio/express-openapi-validator/commit/b3d7483)) +* v5.1.4 ([509fa22](https://github.com/cdimascio/express-openapi-validator/commit/509fa22)) +* fix: #887 allow multiple params with wildcard (#898) ([2d33d0a](https://github.com/cdimascio/express-openapi-validator/commit/2d33d0a)), closes [#887](https://github.com/cdimascio/express-openapi-validator/issues/887) [#898](https://github.com/cdimascio/express-openapi-validator/issues/898) [#1](https://github.com/cdimascio/express-openapi-validator/issues/1) +* docs: fix doc typo in README.md (#885) ([8a81bf8](https://github.com/cdimascio/express-openapi-validator/commit/8a81bf8)), closes [#885](https://github.com/cdimascio/express-openapi-validator/issues/885) + + ## 5.1.3 (2024-01-27) -- CLS Context is lost after using multer middleware (#695) ([40716fb](https://github.com/cdimascio/express-openapi-validator/commit/40716fb)), closes [#695](https://github.com/cdimascio/express-openapi-validator/issues/695) -- remove examples from schema (#890) ([0ad49ec](https://github.com/cdimascio/express-openapi-validator/commit/0ad49ec)), closes [#890](https://github.com/cdimascio/express-openapi-validator/issues/890) -- v5.1.3 ([f806690](https://github.com/cdimascio/express-openapi-validator/commit/f806690)) -- v5.1.3 ([e567701](https://github.com/cdimascio/express-openapi-validator/commit/e567701)) +* CLS Context is lost after using multer middleware (#695) ([40716fb](https://github.com/cdimascio/express-openapi-validator/commit/40716fb)), closes [#695](https://github.com/cdimascio/express-openapi-validator/issues/695) +* remove examples from schema (#890) ([0ad49ec](https://github.com/cdimascio/express-openapi-validator/commit/0ad49ec)), closes [#890](https://github.com/cdimascio/express-openapi-validator/issues/890) +* v5.1.3 ([f806690](https://github.com/cdimascio/express-openapi-validator/commit/f806690)) +* v5.1.3 ([e567701](https://github.com/cdimascio/express-openapi-validator/commit/e567701)) + + ## 5.1.2 (2023-12-04) -- Normalize request body ContentTypes (#863) ([0099b0d](https://github.com/cdimascio/express-openapi-validator/commit/0099b0d)), closes [#863](https://github.com/cdimascio/express-openapi-validator/issues/863) -- Safer handling of multipart nested JSON body props (#878) ([807e09c](https://github.com/cdimascio/express-openapi-validator/commit/807e09c)), closes [#878](https://github.com/cdimascio/express-openapi-validator/issues/878) -- v5.1.1 ([4b0c989](https://github.com/cdimascio/express-openapi-validator/commit/4b0c989)) +* Normalize request body ContentTypes (#863) ([0099b0d](https://github.com/cdimascio/express-openapi-validator/commit/0099b0d)), closes [#863](https://github.com/cdimascio/express-openapi-validator/issues/863) +* Safer handling of multipart nested JSON body props (#878) ([807e09c](https://github.com/cdimascio/express-openapi-validator/commit/807e09c)), closes [#878](https://github.com/cdimascio/express-openapi-validator/issues/878) +* v5.1.1 ([4b0c989](https://github.com/cdimascio/express-openapi-validator/commit/4b0c989)) + + ## 5.1.1 (2023-11-21) -- Pass-through HttpError caught in multipart handler (#867) ([240c876](https://github.com/cdimascio/express-openapi-validator/commit/240c876)), closes [#867](https://github.com/cdimascio/express-openapi-validator/issues/867) -- v5.1.0 ([a9a3b0b](https://github.com/cdimascio/express-openapi-validator/commit/a9a3b0b)) -- v5.1.1 ([a4e62ac](https://github.com/cdimascio/express-openapi-validator/commit/a4e62ac)) +* Pass-through HttpError caught in multipart handler (#867) ([240c876](https://github.com/cdimascio/express-openapi-validator/commit/240c876)), closes [#867](https://github.com/cdimascio/express-openapi-validator/issues/867) +* v5.1.0 ([a9a3b0b](https://github.com/cdimascio/express-openapi-validator/commit/a9a3b0b)) +* v5.1.1 ([a4e62ac](https://github.com/cdimascio/express-openapi-validator/commit/a4e62ac)) + + ## 5.1.0 (2023-11-12) -- Allow optional use of `req.url` (#857) ([f732379](https://github.com/cdimascio/express-openapi-validator/commit/f732379)), closes [#857](https://github.com/cdimascio/express-openapi-validator/issues/857) -- Reorder upload and security middlewares (#866) ([95543d6](https://github.com/cdimascio/express-openapi-validator/commit/95543d6)), closes [#866](https://github.com/cdimascio/express-openapi-validator/issues/866) [#865](https://github.com/cdimascio/express-openapi-validator/issues/865) -- Update build and packaging scripts (#872) ([dd4027f](https://github.com/cdimascio/express-openapi-validator/commit/dd4027f)), closes [#872](https://github.com/cdimascio/express-openapi-validator/issues/872) -- update version locks ([bb8d6b8](https://github.com/cdimascio/express-openapi-validator/commit/bb8d6b8)) -- v5.1.0 ([839f859](https://github.com/cdimascio/express-openapi-validator/commit/839f859)) +* Allow optional use of `req.url` (#857) ([f732379](https://github.com/cdimascio/express-openapi-validator/commit/f732379)), closes [#857](https://github.com/cdimascio/express-openapi-validator/issues/857) +* Reorder upload and security middlewares (#866) ([95543d6](https://github.com/cdimascio/express-openapi-validator/commit/95543d6)), closes [#866](https://github.com/cdimascio/express-openapi-validator/issues/866) [#865](https://github.com/cdimascio/express-openapi-validator/issues/865) +* Update build and packaging scripts (#872) ([dd4027f](https://github.com/cdimascio/express-openapi-validator/commit/dd4027f)), closes [#872](https://github.com/cdimascio/express-openapi-validator/issues/872) +* update version locks ([bb8d6b8](https://github.com/cdimascio/express-openapi-validator/commit/bb8d6b8)) +* v5.1.0 ([839f859](https://github.com/cdimascio/express-openapi-validator/commit/839f859)) + + ## 5.0.5 (2023-08-23) -- #841 return error thrown in serDes deserializer (#842) ([d029401](https://github.com/cdimascio/express-openapi-validator/commit/d029401)), closes [#841](https://github.com/cdimascio/express-openapi-validator/issues/841) [#842](https://github.com/cdimascio/express-openapi-validator/issues/842) -- fix documentation links ([01950b7](https://github.com/cdimascio/express-openapi-validator/commit/01950b7)) -- fix example schema removal and upgrade patch version ([495dabd](https://github.com/cdimascio/express-openapi-validator/commit/495dabd)) -- fixing default export function issue (#846) ([268d38a](https://github.com/cdimascio/express-openapi-validator/commit/268d38a)), closes [#846](https://github.com/cdimascio/express-openapi-validator/issues/846) -- Remove body-parser deps in example (#845) ([c73b7c1](https://github.com/cdimascio/express-openapi-validator/commit/c73b7c1)), closes [#845](https://github.com/cdimascio/express-openapi-validator/issues/845) -- Remove examples from apiDoc when validating requests (#774) ([950d429](https://github.com/cdimascio/express-openapi-validator/commit/950d429)), closes [#774](https://github.com/cdimascio/express-openapi-validator/issues/774) -- Resolve "reference resolves to more than one schema" errors when AJV processes OpenAPI document and ([9d215be](https://github.com/cdimascio/express-openapi-validator/commit/9d215be)), closes [#853](https://github.com/cdimascio/express-openapi-validator/issues/853) -- v5.0.5 change history ([b5cc33a](https://github.com/cdimascio/express-openapi-validator/commit/b5cc33a)) +* #841 return error thrown in serDes deserializer (#842) ([d029401](https://github.com/cdimascio/express-openapi-validator/commit/d029401)), closes [#841](https://github.com/cdimascio/express-openapi-validator/issues/841) [#842](https://github.com/cdimascio/express-openapi-validator/issues/842) +* fix documentation links ([01950b7](https://github.com/cdimascio/express-openapi-validator/commit/01950b7)) +* fix example schema removal and upgrade patch version ([495dabd](https://github.com/cdimascio/express-openapi-validator/commit/495dabd)) +* fixing default export function issue (#846) ([268d38a](https://github.com/cdimascio/express-openapi-validator/commit/268d38a)), closes [#846](https://github.com/cdimascio/express-openapi-validator/issues/846) +* Remove body-parser deps in example (#845) ([c73b7c1](https://github.com/cdimascio/express-openapi-validator/commit/c73b7c1)), closes [#845](https://github.com/cdimascio/express-openapi-validator/issues/845) +* Remove examples from apiDoc when validating requests (#774) ([950d429](https://github.com/cdimascio/express-openapi-validator/commit/950d429)), closes [#774](https://github.com/cdimascio/express-openapi-validator/issues/774) +* Resolve "reference resolves to more than one schema" errors when AJV processes OpenAPI document and ([9d215be](https://github.com/cdimascio/express-openapi-validator/commit/9d215be)), closes [#853](https://github.com/cdimascio/express-openapi-validator/issues/853) +* v5.0.5 change history ([b5cc33a](https://github.com/cdimascio/express-openapi-validator/commit/b5cc33a)) + + ## 5.0.4 (2023-04-30) -- Switch json-schema-ref-parser to non-deprecated package (#829) ([f5bbce9](https://github.com/cdimascio/express-openapi-validator/commit/f5bbce9)), closes [#829](https://github.com/cdimascio/express-openapi-validator/issues/829) -- v5.0.4 ([9b89c79](https://github.com/cdimascio/express-openapi-validator/commit/9b89c79)) -- fix: Deserialize custom types with inline schemas (#823) ([d53621d](https://github.com/cdimascio/express-openapi-validator/commit/d53621d)), closes [#823](https://github.com/cdimascio/express-openapi-validator/issues/823) +* Switch json-schema-ref-parser to non-deprecated package (#829) ([f5bbce9](https://github.com/cdimascio/express-openapi-validator/commit/f5bbce9)), closes [#829](https://github.com/cdimascio/express-openapi-validator/issues/829) +* v5.0.4 ([9b89c79](https://github.com/cdimascio/express-openapi-validator/commit/9b89c79)) +* fix: Deserialize custom types with inline schemas (#823) ([d53621d](https://github.com/cdimascio/express-openapi-validator/commit/d53621d)), closes [#823](https://github.com/cdimascio/express-openapi-validator/issues/823) + + ## 5.0.3 (2023-03-04) -- FIx serialization/deserialization in additionalProperties (#822) ([a9067b8](https://github.com/cdimascio/express-openapi-validator/commit/a9067b8)), closes [#822](https://github.com/cdimascio/express-openapi-validator/issues/822) -- Rename field `error_code` to `errorCode` in `ValidationErrorItem` (#819) ([1a1b2cc](https://github.com/cdimascio/express-openapi-validator/commit/1a1b2cc)), closes [#819](https://github.com/cdimascio/express-openapi-validator/issues/819) -- v5.0.3 ([6e93a96](https://github.com/cdimascio/express-openapi-validator/commit/6e93a96)) -- chore(deps): bump cookiejar from 2.1.2 to 2.1.4 in /examples/9-nestjs (#805) ([07d9879](https://github.com/cdimascio/express-openapi-validator/commit/07d9879)), closes [#805](https://github.com/cdimascio/express-openapi-validator/issues/805) -- chore(deps): bump cookiejar from 2.1.3 to 2.1.4 (#806) ([0da34f8](https://github.com/cdimascio/express-openapi-validator/commit/0da34f8)), closes [#806](https://github.com/cdimascio/express-openapi-validator/issues/806) -- chore(deps): bump http-cache-semantics (#811) ([7a779f6](https://github.com/cdimascio/express-openapi-validator/commit/7a779f6)), closes [#811](https://github.com/cdimascio/express-openapi-validator/issues/811) -- chore(deps): bump http-cache-semantics (#813) ([336683d](https://github.com/cdimascio/express-openapi-validator/commit/336683d)), closes [#813](https://github.com/cdimascio/express-openapi-validator/issues/813) -- chore(deps): bump http-cache-semantics (#814) ([3721092](https://github.com/cdimascio/express-openapi-validator/commit/3721092)), closes [#814](https://github.com/cdimascio/express-openapi-validator/issues/814) -- chore(deps): bump http-cache-semantics (#816) ([466e337](https://github.com/cdimascio/express-openapi-validator/commit/466e337)), closes [#816](https://github.com/cdimascio/express-openapi-validator/issues/816) -- chore(deps): bump http-cache-semantics (#817) ([582b395](https://github.com/cdimascio/express-openapi-validator/commit/582b395)), closes [#817](https://github.com/cdimascio/express-openapi-validator/issues/817) -- chore(deps): bump http-cache-semantics in /examples/1-standard (#810) ([e6ef9d3](https://github.com/cdimascio/express-openapi-validator/commit/e6ef9d3)), closes [#810](https://github.com/cdimascio/express-openapi-validator/issues/810) -- chore(deps): bump http-cache-semantics in /examples/3-eov-operations (#812) ([fd04b5e](https://github.com/cdimascio/express-openapi-validator/commit/fd04b5e)), closes [#812](https://github.com/cdimascio/express-openapi-validator/issues/812) -- chore(deps): bump http-cache-semantics in /examples/6-multi-file-spec (#815) ([b2704b0](https://github.com/cdimascio/express-openapi-validator/commit/b2704b0)), closes [#815](https://github.com/cdimascio/express-openapi-validator/issues/815) -- chore(deps): bump json5 from 1.0.1 to 1.0.2 in /examples/9-nestjs (#801) ([30defdc](https://github.com/cdimascio/express-openapi-validator/commit/30defdc)), closes [#801](https://github.com/cdimascio/express-openapi-validator/issues/801) -- chore(deps): bump json5 in /examples/4-eov-operations-babel (#799) ([a100192](https://github.com/cdimascio/express-openapi-validator/commit/a100192)), closes [#799](https://github.com/cdimascio/express-openapi-validator/issues/799) -- fix: upgrade ajv from 8.11.0 to 8.11.2 (#797) ([e774d4b](https://github.com/cdimascio/express-openapi-validator/commit/e774d4b)), closes [#797](https://github.com/cdimascio/express-openapi-validator/issues/797) -- fix: upgrade body-parser from 1.19.0 to 1.20.1 (#798) ([87a2000](https://github.com/cdimascio/express-openapi-validator/commit/87a2000)), closes [#798](https://github.com/cdimascio/express-openapi-validator/issues/798) -- fix: upgrade content-type from 1.0.4 to 1.0.5 (#818) ([541d5f9](https://github.com/cdimascio/express-openapi-validator/commit/541d5f9)), closes [#818](https://github.com/cdimascio/express-openapi-validator/issues/818) +* FIx serialization/deserialization in additionalProperties (#822) ([a9067b8](https://github.com/cdimascio/express-openapi-validator/commit/a9067b8)), closes [#822](https://github.com/cdimascio/express-openapi-validator/issues/822) +* Rename field `error_code` to `errorCode` in `ValidationErrorItem` (#819) ([1a1b2cc](https://github.com/cdimascio/express-openapi-validator/commit/1a1b2cc)), closes [#819](https://github.com/cdimascio/express-openapi-validator/issues/819) +* v5.0.3 ([6e93a96](https://github.com/cdimascio/express-openapi-validator/commit/6e93a96)) +* chore(deps): bump cookiejar from 2.1.2 to 2.1.4 in /examples/9-nestjs (#805) ([07d9879](https://github.com/cdimascio/express-openapi-validator/commit/07d9879)), closes [#805](https://github.com/cdimascio/express-openapi-validator/issues/805) +* chore(deps): bump cookiejar from 2.1.3 to 2.1.4 (#806) ([0da34f8](https://github.com/cdimascio/express-openapi-validator/commit/0da34f8)), closes [#806](https://github.com/cdimascio/express-openapi-validator/issues/806) +* chore(deps): bump http-cache-semantics (#811) ([7a779f6](https://github.com/cdimascio/express-openapi-validator/commit/7a779f6)), closes [#811](https://github.com/cdimascio/express-openapi-validator/issues/811) +* chore(deps): bump http-cache-semantics (#813) ([336683d](https://github.com/cdimascio/express-openapi-validator/commit/336683d)), closes [#813](https://github.com/cdimascio/express-openapi-validator/issues/813) +* chore(deps): bump http-cache-semantics (#814) ([3721092](https://github.com/cdimascio/express-openapi-validator/commit/3721092)), closes [#814](https://github.com/cdimascio/express-openapi-validator/issues/814) +* chore(deps): bump http-cache-semantics (#816) ([466e337](https://github.com/cdimascio/express-openapi-validator/commit/466e337)), closes [#816](https://github.com/cdimascio/express-openapi-validator/issues/816) +* chore(deps): bump http-cache-semantics (#817) ([582b395](https://github.com/cdimascio/express-openapi-validator/commit/582b395)), closes [#817](https://github.com/cdimascio/express-openapi-validator/issues/817) +* chore(deps): bump http-cache-semantics in /examples/1-standard (#810) ([e6ef9d3](https://github.com/cdimascio/express-openapi-validator/commit/e6ef9d3)), closes [#810](https://github.com/cdimascio/express-openapi-validator/issues/810) +* chore(deps): bump http-cache-semantics in /examples/3-eov-operations (#812) ([fd04b5e](https://github.com/cdimascio/express-openapi-validator/commit/fd04b5e)), closes [#812](https://github.com/cdimascio/express-openapi-validator/issues/812) +* chore(deps): bump http-cache-semantics in /examples/6-multi-file-spec (#815) ([b2704b0](https://github.com/cdimascio/express-openapi-validator/commit/b2704b0)), closes [#815](https://github.com/cdimascio/express-openapi-validator/issues/815) +* chore(deps): bump json5 from 1.0.1 to 1.0.2 in /examples/9-nestjs (#801) ([30defdc](https://github.com/cdimascio/express-openapi-validator/commit/30defdc)), closes [#801](https://github.com/cdimascio/express-openapi-validator/issues/801) +* chore(deps): bump json5 in /examples/4-eov-operations-babel (#799) ([a100192](https://github.com/cdimascio/express-openapi-validator/commit/a100192)), closes [#799](https://github.com/cdimascio/express-openapi-validator/issues/799) +* fix: upgrade ajv from 8.11.0 to 8.11.2 (#797) ([e774d4b](https://github.com/cdimascio/express-openapi-validator/commit/e774d4b)), closes [#797](https://github.com/cdimascio/express-openapi-validator/issues/797) +* fix: upgrade body-parser from 1.19.0 to 1.20.1 (#798) ([87a2000](https://github.com/cdimascio/express-openapi-validator/commit/87a2000)), closes [#798](https://github.com/cdimascio/express-openapi-validator/issues/798) +* fix: upgrade content-type from 1.0.4 to 1.0.5 (#818) ([541d5f9](https://github.com/cdimascio/express-openapi-validator/commit/541d5f9)), closes [#818](https://github.com/cdimascio/express-openapi-validator/issues/818) + + ## 5.0.2 (2023-02-11) -- v5.0.2 ([3b0e70c](https://github.com/cdimascio/express-openapi-validator/commit/3b0e70c)) -- v5.0.2 ([24ad64f](https://github.com/cdimascio/express-openapi-validator/commit/24ad64f)) -- fix: objects in form-data (#730) ([e5cb5d6](https://github.com/cdimascio/express-openapi-validator/commit/e5cb5d6)), closes [#730](https://github.com/cdimascio/express-openapi-validator/issues/730) +* v5.0.2 ([3b0e70c](https://github.com/cdimascio/express-openapi-validator/commit/3b0e70c)) +* v5.0.2 ([24ad64f](https://github.com/cdimascio/express-openapi-validator/commit/24ad64f)) +* fix: objects in form-data (#730) ([e5cb5d6](https://github.com/cdimascio/express-openapi-validator/commit/e5cb5d6)), closes [#730](https://github.com/cdimascio/express-openapi-validator/issues/730) + + ## 5.0.1 (2023-01-09) -- enhance SchemaObject type (#697) ([ca43431](https://github.com/cdimascio/express-openapi-validator/commit/ca43431)), closes [#697](https://github.com/cdimascio/express-openapi-validator/issues/697) -- implement github actions workflow (#793) ([d415425](https://github.com/cdimascio/express-openapi-validator/commit/d415425)), closes [#793](https://github.com/cdimascio/express-openapi-validator/issues/793) -- Update README.md ([33da583](https://github.com/cdimascio/express-openapi-validator/commit/33da583)) -- Update README.md ([ccd981a](https://github.com/cdimascio/express-openapi-validator/commit/ccd981a)) -- v5.0.1 ([de0708b](https://github.com/cdimascio/express-openapi-validator/commit/de0708b)) -- chore(deps): bump ansi-regex from 3.0.0 to 3.0.1 in /examples/9-nestjs (#738) ([60afead](https://github.com/cdimascio/express-openapi-validator/commit/60afead)), closes [#738](https://github.com/cdimascio/express-openapi-validator/issues/738) -- chore(deps): bump minimatch from 3.0.4 to 3.1.2 in /examples/1-standard (#764) ([0d04305](https://github.com/cdimascio/express-openapi-validator/commit/0d04305)), closes [#764](https://github.com/cdimascio/express-openapi-validator/issues/764) -- chore(deps): bump minimatch from 3.0.4 to 3.1.2 in /examples/9-nestjs (#760) ([c1cf0d9](https://github.com/cdimascio/express-openapi-validator/commit/c1cf0d9)), closes [#760](https://github.com/cdimascio/express-openapi-validator/issues/760) -- chore(deps): bump minimatch in /examples/2-standard-multiple-api-specs (#763) ([fe5e95e](https://github.com/cdimascio/express-openapi-validator/commit/fe5e95e)), closes [#763](https://github.com/cdimascio/express-openapi-validator/issues/763) -- chore(deps): bump minimatch in /examples/3-eov-operations (#766) ([3285f3a](https://github.com/cdimascio/express-openapi-validator/commit/3285f3a)), closes [#766](https://github.com/cdimascio/express-openapi-validator/issues/766) -- chore(deps): bump minimatch in /examples/4-eov-operations-babel (#768) ([5bcc81b](https://github.com/cdimascio/express-openapi-validator/commit/5bcc81b)), closes [#768](https://github.com/cdimascio/express-openapi-validator/issues/768) -- chore(deps): bump minimatch in /examples/5-custom-operation-resolver (#765) ([b5b03b3](https://github.com/cdimascio/express-openapi-validator/commit/b5b03b3)), closes [#765](https://github.com/cdimascio/express-openapi-validator/issues/765) -- chore(deps): bump minimatch in /examples/6-multi-file-spec (#767) ([e8f54e8](https://github.com/cdimascio/express-openapi-validator/commit/e8f54e8)), closes [#767](https://github.com/cdimascio/express-openapi-validator/issues/767) -- chore(deps): bump minimatch in /examples/7-response-date-serialization (#759) ([9b9433e](https://github.com/cdimascio/express-openapi-validator/commit/9b9433e)), closes [#759](https://github.com/cdimascio/express-openapi-validator/issues/759) -- chore(deps): bump minimatch in /examples/8-top-level-discriminator (#761) ([46afe5c](https://github.com/cdimascio/express-openapi-validator/commit/46afe5c)), closes [#761](https://github.com/cdimascio/express-openapi-validator/issues/761) -- chore(deps): bump minimist and @nestjs/cli in /examples/9-nestjs (#769) ([8d31f9a](https://github.com/cdimascio/express-openapi-validator/commit/8d31f9a)), closes [#769](https://github.com/cdimascio/express-openapi-validator/issues/769) -- chore(deps): bump terser from 5.7.2 to 5.14.2 in /examples/9-nestjs (#750) ([a83ff9d](https://github.com/cdimascio/express-openapi-validator/commit/a83ff9d)), closes [#750](https://github.com/cdimascio/express-openapi-validator/issues/750) -- fix: upgrade body-parser from 1.19.0 to 1.19.1 (#689) ([40736f8](https://github.com/cdimascio/express-openapi-validator/commit/40736f8)), closes [#689](https://github.com/cdimascio/express-openapi-validator/issues/689) -- fix: upgrade body-parser from 1.19.0 to 1.19.1 (#690) ([9038edc](https://github.com/cdimascio/express-openapi-validator/commit/9038edc)), closes [#690](https://github.com/cdimascio/express-openapi-validator/issues/690) -- fix: upgrade body-parser from 1.19.0 to 1.19.1 (#691) ([e64a91c](https://github.com/cdimascio/express-openapi-validator/commit/e64a91c)), closes [#691](https://github.com/cdimascio/express-openapi-validator/issues/691) +* enhance SchemaObject type (#697) ([ca43431](https://github.com/cdimascio/express-openapi-validator/commit/ca43431)), closes [#697](https://github.com/cdimascio/express-openapi-validator/issues/697) +* implement github actions workflow (#793) ([d415425](https://github.com/cdimascio/express-openapi-validator/commit/d415425)), closes [#793](https://github.com/cdimascio/express-openapi-validator/issues/793) +* Update README.md ([33da583](https://github.com/cdimascio/express-openapi-validator/commit/33da583)) +* Update README.md ([ccd981a](https://github.com/cdimascio/express-openapi-validator/commit/ccd981a)) +* v5.0.1 ([de0708b](https://github.com/cdimascio/express-openapi-validator/commit/de0708b)) +* chore(deps): bump ansi-regex from 3.0.0 to 3.0.1 in /examples/9-nestjs (#738) ([60afead](https://github.com/cdimascio/express-openapi-validator/commit/60afead)), closes [#738](https://github.com/cdimascio/express-openapi-validator/issues/738) +* chore(deps): bump minimatch from 3.0.4 to 3.1.2 in /examples/1-standard (#764) ([0d04305](https://github.com/cdimascio/express-openapi-validator/commit/0d04305)), closes [#764](https://github.com/cdimascio/express-openapi-validator/issues/764) +* chore(deps): bump minimatch from 3.0.4 to 3.1.2 in /examples/9-nestjs (#760) ([c1cf0d9](https://github.com/cdimascio/express-openapi-validator/commit/c1cf0d9)), closes [#760](https://github.com/cdimascio/express-openapi-validator/issues/760) +* chore(deps): bump minimatch in /examples/2-standard-multiple-api-specs (#763) ([fe5e95e](https://github.com/cdimascio/express-openapi-validator/commit/fe5e95e)), closes [#763](https://github.com/cdimascio/express-openapi-validator/issues/763) +* chore(deps): bump minimatch in /examples/3-eov-operations (#766) ([3285f3a](https://github.com/cdimascio/express-openapi-validator/commit/3285f3a)), closes [#766](https://github.com/cdimascio/express-openapi-validator/issues/766) +* chore(deps): bump minimatch in /examples/4-eov-operations-babel (#768) ([5bcc81b](https://github.com/cdimascio/express-openapi-validator/commit/5bcc81b)), closes [#768](https://github.com/cdimascio/express-openapi-validator/issues/768) +* chore(deps): bump minimatch in /examples/5-custom-operation-resolver (#765) ([b5b03b3](https://github.com/cdimascio/express-openapi-validator/commit/b5b03b3)), closes [#765](https://github.com/cdimascio/express-openapi-validator/issues/765) +* chore(deps): bump minimatch in /examples/6-multi-file-spec (#767) ([e8f54e8](https://github.com/cdimascio/express-openapi-validator/commit/e8f54e8)), closes [#767](https://github.com/cdimascio/express-openapi-validator/issues/767) +* chore(deps): bump minimatch in /examples/7-response-date-serialization (#759) ([9b9433e](https://github.com/cdimascio/express-openapi-validator/commit/9b9433e)), closes [#759](https://github.com/cdimascio/express-openapi-validator/issues/759) +* chore(deps): bump minimatch in /examples/8-top-level-discriminator (#761) ([46afe5c](https://github.com/cdimascio/express-openapi-validator/commit/46afe5c)), closes [#761](https://github.com/cdimascio/express-openapi-validator/issues/761) +* chore(deps): bump minimist and @nestjs/cli in /examples/9-nestjs (#769) ([8d31f9a](https://github.com/cdimascio/express-openapi-validator/commit/8d31f9a)), closes [#769](https://github.com/cdimascio/express-openapi-validator/issues/769) +* chore(deps): bump terser from 5.7.2 to 5.14.2 in /examples/9-nestjs (#750) ([a83ff9d](https://github.com/cdimascio/express-openapi-validator/commit/a83ff9d)), closes [#750](https://github.com/cdimascio/express-openapi-validator/issues/750) +* fix: upgrade body-parser from 1.19.0 to 1.19.1 (#689) ([40736f8](https://github.com/cdimascio/express-openapi-validator/commit/40736f8)), closes [#689](https://github.com/cdimascio/express-openapi-validator/issues/689) +* fix: upgrade body-parser from 1.19.0 to 1.19.1 (#690) ([9038edc](https://github.com/cdimascio/express-openapi-validator/commit/9038edc)), closes [#690](https://github.com/cdimascio/express-openapi-validator/issues/690) +* fix: upgrade body-parser from 1.19.0 to 1.19.1 (#691) ([e64a91c](https://github.com/cdimascio/express-openapi-validator/commit/e64a91c)), closes [#691](https://github.com/cdimascio/express-openapi-validator/issues/691) + + ## 5.0.0 (2022-11-19) -- Fix #699 serdes missed on items in a collection, with tests. (#704) ([77bc4ae](https://github.com/cdimascio/express-openapi-validator/commit/77bc4ae)), closes [#699](https://github.com/cdimascio/express-openapi-validator/issues/699) [#704](https://github.com/cdimascio/express-openapi-validator/issues/704) -- fixed router parameters (#762) ([2bbed6f](https://github.com/cdimascio/express-openapi-validator/commit/2bbed6f)), closes [#762](https://github.com/cdimascio/express-openapi-validator/issues/762) -- v5.0.0 with ajv8 ([1d1d71b](https://github.com/cdimascio/express-openapi-validator/commit/1d1d71b)) +* Fix #699 serdes missed on items in a collection, with tests. (#704) ([77bc4ae](https://github.com/cdimascio/express-openapi-validator/commit/77bc4ae)), closes [#699](https://github.com/cdimascio/express-openapi-validator/issues/699) [#704](https://github.com/cdimascio/express-openapi-validator/issues/704) +* fixed router parameters (#762) ([2bbed6f](https://github.com/cdimascio/express-openapi-validator/commit/2bbed6f)), closes [#762](https://github.com/cdimascio/express-openapi-validator/issues/762) +* v5.0.0 with ajv8 ([1d1d71b](https://github.com/cdimascio/express-openapi-validator/commit/1d1d71b)) + + ## 4.13.8 (2022-05-30) -- Bump AJV to v8 (#713) ([2b27332](https://github.com/cdimascio/express-openapi-validator/commit/2b27332)), closes [#713](https://github.com/cdimascio/express-openapi-validator/issues/713) -- Bump multer to version that removes dicer as sub-dependency (#739) ([6501a62](https://github.com/cdimascio/express-openapi-validator/commit/6501a62)), closes [#739](https://github.com/cdimascio/express-openapi-validator/issues/739) -- update ansi-regex ([6448f45](https://github.com/cdimascio/express-openapi-validator/commit/6448f45)) -- Update README.md ([c954b4b](https://github.com/cdimascio/express-openapi-validator/commit/c954b4b)) -- v4.14.0-beta.1 ([369a4a6](https://github.com/cdimascio/express-openapi-validator/commit/369a4a6)) -- v4.14.0-beta.2 ([1706538](https://github.com/cdimascio/express-openapi-validator/commit/1706538)) -- chore(deps): bump ansi-regex in /examples/2-standard-multiple-api-specs (#727) ([3e803b5](https://github.com/cdimascio/express-openapi-validator/commit/3e803b5)), closes [#727](https://github.com/cdimascio/express-openapi-validator/issues/727) -- chore(deps): bump ansi-regex in /examples/3-eov-operations (#726) ([aba3cd0](https://github.com/cdimascio/express-openapi-validator/commit/aba3cd0)), closes [#726](https://github.com/cdimascio/express-openapi-validator/issues/726) -- chore(deps): bump ansi-regex in /examples/5-custom-operation-resolver (#725) ([2bf250e](https://github.com/cdimascio/express-openapi-validator/commit/2bf250e)), closes [#725](https://github.com/cdimascio/express-openapi-validator/issues/725) -- chore(deps): bump ansi-regex in /examples/6-multi-file-spec (#723) ([e29c1eb](https://github.com/cdimascio/express-openapi-validator/commit/e29c1eb)), closes [#723](https://github.com/cdimascio/express-openapi-validator/issues/723) -- chore(deps): bump ansi-regex in /examples/7-response-date-serialization (#722) ([acdae50](https://github.com/cdimascio/express-openapi-validator/commit/acdae50)), closes [#722](https://github.com/cdimascio/express-openapi-validator/issues/722) -- chore(deps): bump ansi-regex in /examples/8-top-level-discriminator (#719) ([45059a6](https://github.com/cdimascio/express-openapi-validator/commit/45059a6)), closes [#719](https://github.com/cdimascio/express-openapi-validator/issues/719) -- chore(deps): bump follow-redirects in /examples/9-nestjs (#705) ([15e91aa](https://github.com/cdimascio/express-openapi-validator/commit/15e91aa)), closes [#705](https://github.com/cdimascio/express-openapi-validator/issues/705) -- chore(deps): bump minimist from 1.2.5 to 1.2.6 in /examples/1-standard (#714) ([1eecf40](https://github.com/cdimascio/express-openapi-validator/commit/1eecf40)), closes [#714](https://github.com/cdimascio/express-openapi-validator/issues/714) -- chore(deps): bump minimist in /examples/2-standard-multiple-api-specs (#716) ([6f6ea71](https://github.com/cdimascio/express-openapi-validator/commit/6f6ea71)), closes [#716](https://github.com/cdimascio/express-openapi-validator/issues/716) -- chore(deps): bump minimist in /examples/3-eov-operations (#715) ([3f6cb37](https://github.com/cdimascio/express-openapi-validator/commit/3f6cb37)), closes [#715](https://github.com/cdimascio/express-openapi-validator/issues/715) -- chore(deps): bump minimist in /examples/4-eov-operations-babel (#717) ([6b90f35](https://github.com/cdimascio/express-openapi-validator/commit/6b90f35)), closes [#717](https://github.com/cdimascio/express-openapi-validator/issues/717) -- chore(deps): bump minimist in /examples/5-custom-operation-resolver (#718) ([acc3f33](https://github.com/cdimascio/express-openapi-validator/commit/acc3f33)), closes [#718](https://github.com/cdimascio/express-openapi-validator/issues/718) -- chore(deps): bump minimist in /examples/6-multi-file-spec (#724) ([15814ba](https://github.com/cdimascio/express-openapi-validator/commit/15814ba)), closes [#724](https://github.com/cdimascio/express-openapi-validator/issues/724) -- chore(deps): bump minimist in /examples/7-response-date-serialization (#721) ([ff63618](https://github.com/cdimascio/express-openapi-validator/commit/ff63618)), closes [#721](https://github.com/cdimascio/express-openapi-validator/issues/721) -- chore(deps): bump minimist in /examples/8-top-level-discriminator (#720) ([a23a09f](https://github.com/cdimascio/express-openapi-validator/commit/a23a09f)), closes [#720](https://github.com/cdimascio/express-openapi-validator/issues/720) -- chore(deps): bump node-fetch from 2.6.1 to 2.6.7 in /examples/9-nestjs (#711) ([87bb6df](https://github.com/cdimascio/express-openapi-validator/commit/87bb6df)), closes [#711](https://github.com/cdimascio/express-openapi-validator/issues/711) +* Bump AJV to v8 (#713) ([2b27332](https://github.com/cdimascio/express-openapi-validator/commit/2b27332)), closes [#713](https://github.com/cdimascio/express-openapi-validator/issues/713) +* Bump multer to version that removes dicer as sub-dependency (#739) ([6501a62](https://github.com/cdimascio/express-openapi-validator/commit/6501a62)), closes [#739](https://github.com/cdimascio/express-openapi-validator/issues/739) +* update ansi-regex ([6448f45](https://github.com/cdimascio/express-openapi-validator/commit/6448f45)) +* Update README.md ([c954b4b](https://github.com/cdimascio/express-openapi-validator/commit/c954b4b)) +* v4.14.0-beta.1 ([369a4a6](https://github.com/cdimascio/express-openapi-validator/commit/369a4a6)) +* v4.14.0-beta.2 ([1706538](https://github.com/cdimascio/express-openapi-validator/commit/1706538)) +* chore(deps): bump ansi-regex in /examples/2-standard-multiple-api-specs (#727) ([3e803b5](https://github.com/cdimascio/express-openapi-validator/commit/3e803b5)), closes [#727](https://github.com/cdimascio/express-openapi-validator/issues/727) +* chore(deps): bump ansi-regex in /examples/3-eov-operations (#726) ([aba3cd0](https://github.com/cdimascio/express-openapi-validator/commit/aba3cd0)), closes [#726](https://github.com/cdimascio/express-openapi-validator/issues/726) +* chore(deps): bump ansi-regex in /examples/5-custom-operation-resolver (#725) ([2bf250e](https://github.com/cdimascio/express-openapi-validator/commit/2bf250e)), closes [#725](https://github.com/cdimascio/express-openapi-validator/issues/725) +* chore(deps): bump ansi-regex in /examples/6-multi-file-spec (#723) ([e29c1eb](https://github.com/cdimascio/express-openapi-validator/commit/e29c1eb)), closes [#723](https://github.com/cdimascio/express-openapi-validator/issues/723) +* chore(deps): bump ansi-regex in /examples/7-response-date-serialization (#722) ([acdae50](https://github.com/cdimascio/express-openapi-validator/commit/acdae50)), closes [#722](https://github.com/cdimascio/express-openapi-validator/issues/722) +* chore(deps): bump ansi-regex in /examples/8-top-level-discriminator (#719) ([45059a6](https://github.com/cdimascio/express-openapi-validator/commit/45059a6)), closes [#719](https://github.com/cdimascio/express-openapi-validator/issues/719) +* chore(deps): bump follow-redirects in /examples/9-nestjs (#705) ([15e91aa](https://github.com/cdimascio/express-openapi-validator/commit/15e91aa)), closes [#705](https://github.com/cdimascio/express-openapi-validator/issues/705) +* chore(deps): bump minimist from 1.2.5 to 1.2.6 in /examples/1-standard (#714) ([1eecf40](https://github.com/cdimascio/express-openapi-validator/commit/1eecf40)), closes [#714](https://github.com/cdimascio/express-openapi-validator/issues/714) +* chore(deps): bump minimist in /examples/2-standard-multiple-api-specs (#716) ([6f6ea71](https://github.com/cdimascio/express-openapi-validator/commit/6f6ea71)), closes [#716](https://github.com/cdimascio/express-openapi-validator/issues/716) +* chore(deps): bump minimist in /examples/3-eov-operations (#715) ([3f6cb37](https://github.com/cdimascio/express-openapi-validator/commit/3f6cb37)), closes [#715](https://github.com/cdimascio/express-openapi-validator/issues/715) +* chore(deps): bump minimist in /examples/4-eov-operations-babel (#717) ([6b90f35](https://github.com/cdimascio/express-openapi-validator/commit/6b90f35)), closes [#717](https://github.com/cdimascio/express-openapi-validator/issues/717) +* chore(deps): bump minimist in /examples/5-custom-operation-resolver (#718) ([acc3f33](https://github.com/cdimascio/express-openapi-validator/commit/acc3f33)), closes [#718](https://github.com/cdimascio/express-openapi-validator/issues/718) +* chore(deps): bump minimist in /examples/6-multi-file-spec (#724) ([15814ba](https://github.com/cdimascio/express-openapi-validator/commit/15814ba)), closes [#724](https://github.com/cdimascio/express-openapi-validator/issues/724) +* chore(deps): bump minimist in /examples/7-response-date-serialization (#721) ([ff63618](https://github.com/cdimascio/express-openapi-validator/commit/ff63618)), closes [#721](https://github.com/cdimascio/express-openapi-validator/issues/721) +* chore(deps): bump minimist in /examples/8-top-level-discriminator (#720) ([a23a09f](https://github.com/cdimascio/express-openapi-validator/commit/a23a09f)), closes [#720](https://github.com/cdimascio/express-openapi-validator/issues/720) +* chore(deps): bump node-fetch from 2.6.1 to 2.6.7 in /examples/9-nestjs (#711) ([87bb6df](https://github.com/cdimascio/express-openapi-validator/commit/87bb6df)), closes [#711](https://github.com/cdimascio/express-openapi-validator/issues/711) + + ## 4.13.7 (2022-03-27) -- migrate README to wiki ([4887ba5](https://github.com/cdimascio/express-openapi-validator/commit/4887ba5)) -- Update README ([13b26d6](https://github.com/cdimascio/express-openapi-validator/commit/13b26d6)) +* migrate README to wiki ([4887ba5](https://github.com/cdimascio/express-openapi-validator/commit/4887ba5)) +* Update README ([13b26d6](https://github.com/cdimascio/express-openapi-validator/commit/13b26d6)) + + + diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index ee9d2140..5d506909 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Gracefully accepting constructive criticism -- Focusing on what is best for the community -- Showing empathy towards other community members +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -- The use of sexualized language or imagery and unwelcome sexual attention or - advances -- Trolling, insulting/derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or electronic - address, without explicit permission -- Other conduct which could reasonably be considered inappropriate in a - professional setting +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting ## Our Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1a8368fc..cd88b86d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,6 @@ Contributors are welcome! See something that needs fixing? Got an idea for a new feature? Contribute a [Pull Request](#Create-a-Pull-Request)! ## Easy path to contribution - Click the Gitpod badge to setup a ready to code dev env in the cloud. [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdimascio/express-openapi-validator) @@ -27,7 +26,7 @@ Click the Gitpod badge to setup a ready to code dev env in the cloud. # From the project directory, run npm i ``` - + Be [Create a Pull Request](#create-a-pull-request) once you've written you code. ## Run the tests @@ -57,12 +56,11 @@ Be [Create a Pull Request](#create-a-pull-request) once you've written you code. 3. Make a new branch 4. Make your changes 5. Push it back to your repo -6. From the Github UI, Click the Compare & pull request button +6. From the Github UI, Click the Compare & pull request button NOTE: this button will be present for some period of time after 5. If the button no longer there, Create pull request and select the branches manually) - -7. From the Github UI, Click Create pull request to open a new pull request -8. Detailed steps with example here: +6. From the Github UI, Click Create pull request to open a new pull request +7. Detailed steps with example here: ## Project structure @@ -76,13 +74,12 @@ Reach out on [gitter](https://gitter.im/cdimascio-oss/community). We're happy to help! ## FAQ - **Q:** I don't have permission to create a branch and I can't push my changes **A:** You cannot directly create a branch in this repo. Instead [Create a Pull Request](#create-a-pull-request) -## Misc +## Misc If you are not a project, you may ignore this section ### Generate Change Log diff --git a/README.md b/README.md index cd79eebf..0ad1a377 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # 🦋 express-openapi-validator -[![example workflow](https://github.com/cdimascio/express-openapi-validator/actions/workflows/default.yml/badge.svg)](#) [![](https://img.shields.io/npm/v/express-openapi-validator.svg)](https://www.npmjs.com/package/express-openapi-validator) [![](https://img.shields.io/npm/dm/express-openapi-validator?color=blue)](https://www.npmjs.com/package/express-openapi-validator) [![All Contributors](https://img.shields.io/github/contributors/cdimascio/express-openapi-validator)](#contributors) [![Coverage Status](https://coveralls.io/repos/github/cdimascio/express-openapi-validator/badge.svg?branch=master)](https://coveralls.io/github/cdimascio/express-openapi-validator?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/1570a06f609345ddb237114bbd6ceed7)](https://www.codacy.com/manual/cdimascio/express-openapi-validator?utm_source=github.com&utm_medium=referral&utm_content=cdimascio/express-openapi-validator&utm_campaign=Badge_Grade) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdimascio/express-openapi-validator) [![](https://img.shields.io/badge/documentation-yes-informational)](https://cdimascio.github.io/express-openapi-validator-documentation/) [![](https://img.shields.io/badge/license-MIT-blue.svg)](#license) +[![example workflow](https://github.com/cdimascio/express-openapi-validator/actions/workflows/default.yml/badge.svg)](#) [![](https://img.shields.io/npm/v/express-openapi-validator.svg)](https://www.npmjs.com/package/express-openapi-validator) [![](https://img.shields.io/npm/dm/express-openapi-validator?color=blue)](https://www.npmjs.com/package/express-openapi-validator) [![All Contributors](https://img.shields.io/github/contributors/cdimascio/express-openapi-validator +)](#contributors) [![Coverage Status](https://coveralls.io/repos/github/cdimascio/express-openapi-validator/badge.svg?branch=master)](https://coveralls.io/github/cdimascio/express-openapi-validator?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/1570a06f609345ddb237114bbd6ceed7)](https://www.codacy.com/manual/cdimascio/express-openapi-validator?utm_source=github.com&utm_medium=referral&utm_content=cdimascio/express-openapi-validator&utm_campaign=Badge_Grade) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdimascio/express-openapi-validator) [![](https://img.shields.io/badge/documentation-yes-informational)](https://cdimascio.github.io/express-openapi-validator-documentation/) [![](https://img.shields.io/badge/license-MIT-blue.svg)](#license) **An OpenApi validator for ExpressJS** that automatically validates **API** _**requests**_ and _**responses**_ using an **OpenAPI 3** specification. @@ -21,7 +22,6 @@ - 🎈 file upload **Docs:** - - 📖 [documentation](https://cdimascio.github.io/express-openapi-validator-documentation/) [![GitHub stars](https://img.shields.io/github/stars/cdimascio/express-openapi-validator.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/cdimascio/express-openapi-validator/stargazers/) [![Twitter URL](https://img.shields.io/twitter/url/https/github.com/cdimascio/express-openapi-validator.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20express-openapi-validator%20by%20%40CarmineDiMascio%20https%3A%2F%2Fgithub.com%2Fcdimascio%2Fexpress-openapi-validator%20%F0%9F%91%8D) @@ -81,7 +81,7 @@ _**Important:** Ensure express is configured with all relevant body parsers. Bod See the [doc](https://cdimascio.github.io/express-openapi-validator-documentation/) for complete documenation -_deprecated_ [legacy doc](https://github.com/cdimascio/express-openapi-validator/wiki) +_deprecated_ [legacy doc](https://github.com/cdimascio/express-openapi-validator/wiki) ## License diff --git a/SECURITY.md b/SECURITY.md index 580ae68c..66ba1532 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -9,6 +9,7 @@ currently being supported with security updates. | ------- | ------------------ | | 5.3.x | :white_check_mark: | + ## Reporting a Vulnerability Use this section to tell people how to report a vulnerability. diff --git a/_config.yml b/_config.yml index 277f1f2c..c4192631 100644 --- a/_config.yml +++ b/_config.yml @@ -1 +1 @@ -theme: jekyll-theme-cayman +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/examples/1-standard-oas-3.1/README.md b/examples/1-standard-oas-3.1/README.md index ecfa6100..27e6e48b 100644 --- a/examples/1-standard-oas-3.1/README.md +++ b/examples/1-standard-oas-3.1/README.md @@ -32,7 +32,6 @@ curl http://localhost:3000/v1/pets ### GET /pets success - ```shell curl -s 'localhost:3000/v1/pets?limit=5' |jq [ @@ -61,8 +60,7 @@ curl -s 'localhost:3000/v1/pets?limit=5' |jq ] ``` -error - +error ```shell curl -s 'localhost:3000/v1/pets' |jq { @@ -81,7 +79,6 @@ error ### POST /pets success - ```shell curl -s -XPOST 'localhost:3000/v1/pets' -d '{"id": 1, "name": "jobe"}' -H 'Content-type: application/json'|jq { @@ -91,7 +88,6 @@ curl -s -XPOST 'localhost:3000/v1/pets' -d '{"id": 1, "name": "jobe"}' -H 'Conte ``` error - ```shell curl -s -XPOST 'localhost:3000/v1/pets' -d '{"id": "sdfsf", "name": "jobe"}' -H 'Content-type: application/json'|jq { @@ -110,7 +106,6 @@ curl -s -XPOST 'localhost:3000/v1/pets' -d '{"id": "sdfsf", "name": "jobe"}' -H ### GET /pets/:id success - ```shell curl -s 'localhost:3000/v1/pets/1' |jq { @@ -124,7 +119,6 @@ curl -s 'localhost:3000/v1/pets/1' |jq ``` error: bad id type - ```shell curl -s 'localhost:3000/v1/pets/lkl' |jq { @@ -140,10 +134,10 @@ curl -s 'localhost:3000/v1/pets/lkl' |jq } ``` + ### /v1/pets/1/photos success - ```shell curl -XPOST 'localhost:3000/v1/pets/1/photos' -H 'Content-type: multipart/form-data' -F 'file=@test.txt'|jq % Total % Received % Xferd Average Speed Time Time Time Current @@ -161,7 +155,6 @@ curl -XPOST 'localhost:3000/v1/pets/1/photos' -H 'Content-type: multipart/form- ``` error: no file - ```shell curl -s -XPOST 'localhost:3000/v1/pets/1/photos' -H 'Content-type: multipart/form-data' |jq { @@ -176,3 +169,4 @@ error: no file "code": 400 } ``` + diff --git a/examples/1-standard-oas-3.1/app.js b/examples/1-standard-oas-3.1/app.js index f600196a..8ee5d613 100644 --- a/examples/1-standard-oas-3.1/app.js +++ b/examples/1-standard-oas-3.1/app.js @@ -79,6 +79,7 @@ app.use((err, req, res, next) => { }); }); + http.createServer(app).listen(port); console.log(`Listening on port ${port}`); diff --git a/examples/1-standard-oas-3.1/services/index.js b/examples/1-standard-oas-3.1/services/index.js index 5e61d4b1..952dc10a 100644 --- a/examples/1-standard-oas-3.1/services/index.js +++ b/examples/1-standard-oas-3.1/services/index.js @@ -24,17 +24,12 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter((d) => !type || d.type === type).slice(0, limit); + return data.filter(d => !type || d.type === type).slice(0, limit); } findById(id) { - console.log( - id, - data, - data.filter((p) => p.id === id), - typeof id, - ); - return data.filter((p) => p.id === id)[0]; + console.log(id, data, data.filter(p => p.id === id), typeof id); + return data.filter(p => p.id === id)[0]; } create(pet) { @@ -44,6 +39,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter((e) => e.id !== id); + return data.filter(e => e.id !== id); } }; diff --git a/examples/1-standard/services/index.js b/examples/1-standard/services/index.js index d7822814..47cef69a 100644 --- a/examples/1-standard/services/index.js +++ b/examples/1-standard/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter((d) => d.type === type).slice(0, limit); + return data.filter(d => d.type === type).slice(0, limit); } findById(id) { - return data.filter((p) => p.id === id)[0]; + return data.filter(p => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter((e) => e.id !== id); + return data.filter(e => e.id !== id); } }; diff --git a/examples/3-eov-operations/routes/pets.js b/examples/3-eov-operations/routes/pets.js index 354f5f9a..0f8c89a3 100644 --- a/examples/3-eov-operations/routes/pets.js +++ b/examples/3-eov-operations/routes/pets.js @@ -23,7 +23,7 @@ module.exports = { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map((f) => ({ + files_metadata: req.files.map(f => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, diff --git a/examples/3-eov-operations/services/index.js b/examples/3-eov-operations/services/index.js index d7822814..1c7afd6e 100644 --- a/examples/3-eov-operations/services/index.js +++ b/examples/3-eov-operations/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter((d) => d.type === type).slice(0, limit); + return data.filter(d => d.type === type).slice(0, limit); } findById(id) { - return data.filter((p) => p.id === id)[0]; + return data.filter(p => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter((e) => e.id !== id); + return data.filter(e => e.id !== id); } -}; +} diff --git a/examples/4-eov-operations-babel/.babelrc b/examples/4-eov-operations-babel/.babelrc index 394c5435..022790fc 100644 --- a/examples/4-eov-operations-babel/.babelrc +++ b/examples/4-eov-operations-babel/.babelrc @@ -1,12 +1,12 @@ { - "presets": [ - [ - "@babel/preset-env", - { - "targets": { - "node": "current" + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "node": "current" + } } - } + ] ] - ] -} + } \ No newline at end of file diff --git a/examples/4-eov-operations-babel/src/api.yaml b/examples/4-eov-operations-babel/src/api.yaml index 9c641f3d..5f8906e4 100644 --- a/examples/4-eov-operations-babel/src/api.yaml +++ b/examples/4-eov-operations-babel/src/api.yaml @@ -15,8 +15,8 @@ paths: description: | ping then pong! # use operationId, (x-eov-operation-id is optional. it can be used in place of operationId or to override it) - operationId: ping - x-eov-operation-handler: routes/ping + operationId: ping + x-eov-operation-handler: routes/ping responses: '200': description: OK diff --git a/examples/4-eov-operations-babel/src/routes/pets.js b/examples/4-eov-operations-babel/src/routes/pets.js index 053ee158..5827b1ac 100644 --- a/examples/4-eov-operations-babel/src/routes/pets.js +++ b/examples/4-eov-operations-babel/src/routes/pets.js @@ -23,7 +23,7 @@ export default { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map((f) => ({ + files_metadata: req.files.map(f => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, diff --git a/examples/4-eov-operations-babel/src/services/index.js b/examples/4-eov-operations-babel/src/services/index.js index d7822814..1c7afd6e 100644 --- a/examples/4-eov-operations-babel/src/services/index.js +++ b/examples/4-eov-operations-babel/src/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter((d) => d.type === type).slice(0, limit); + return data.filter(d => d.type === type).slice(0, limit); } findById(id) { - return data.filter((p) => p.id === id)[0]; + return data.filter(p => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter((e) => e.id !== id); + return data.filter(e => e.id !== id); } -}; +} diff --git a/examples/5-custom-operation-resolver/README.md b/examples/5-custom-operation-resolver/README.md index ade73ffc..f55663ab 100644 --- a/examples/5-custom-operation-resolver/README.md +++ b/examples/5-custom-operation-resolver/README.md @@ -29,7 +29,7 @@ curl http://localhost:3000/v1/pets ## [Example Express API Server: with custom operation resolver](https://github.com/cdimascio/express-openapi-validator/tree/master/examples/5-custom-operation-resolver) -By default, when you configure `operationHandlers` to be the base path to your operation handler files, we use `operationId`, `x-eov-operation-id` and `x-eov-operation-handler` to determine what request handler should be used during routing. +By default, when you configure `operationHandlers` to be the base path to your operation handler files, we use `operationId`, `x-eov-operation-id` and `x-eov-operation-handler` to determine what request handler should be used during routing. If you ever want _FULL_ control over how that resolution happens (e.g. you want to use your own extended attributes or simply rely on `operationId`), then here's how you can accomplish that following an example where our `operationId` becomes a template that follows `{module}.{function}`. @@ -58,20 +58,16 @@ new OpenApiValidator({ } }); ``` - - Next, use `operationId` to specify the id of opeartion handler to invoke. - ```yaml /pets: get: - # This means our resolver will look for a file named "pets.js" at our - # configured base path and will return an export named "list" from + # This means our resolver will look for a file named "pets.js" at our + # configured base path and will return an export named "list" from # that module as the Express RequestHandler. operationId: pets.list ``` - - Finally, create the express handler module e.g. `routes/pets.js` - ```javascript module.exports = { // the express handler implementation for the pets collection diff --git a/examples/5-custom-operation-resolver/api.yaml b/examples/5-custom-operation-resolver/api.yaml index c9e1e721..8b3dd535 100644 --- a/examples/5-custom-operation-resolver/api.yaml +++ b/examples/5-custom-operation-resolver/api.yaml @@ -14,7 +14,7 @@ paths: get: description: | ping then pong! - operationId: ping.ping + operationId: ping.ping responses: '200': description: OK diff --git a/examples/5-custom-operation-resolver/routes/pets.js b/examples/5-custom-operation-resolver/routes/pets.js index cd0e800b..dd51ead9 100644 --- a/examples/5-custom-operation-resolver/routes/pets.js +++ b/examples/5-custom-operation-resolver/routes/pets.js @@ -23,7 +23,7 @@ module.exports = { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map((f) => ({ + files_metadata: req.files.map(f => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, diff --git a/examples/5-custom-operation-resolver/services/index.js b/examples/5-custom-operation-resolver/services/index.js index d7822814..1c7afd6e 100644 --- a/examples/5-custom-operation-resolver/services/index.js +++ b/examples/5-custom-operation-resolver/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter((d) => d.type === type).slice(0, limit); + return data.filter(d => d.type === type).slice(0, limit); } findById(id) { - return data.filter((p) => p.id === id)[0]; + return data.filter(p => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter((e) => e.id !== id); + return data.filter(e => e.id !== id); } -}; +} diff --git a/examples/6-multi-file-spec/README.md b/examples/6-multi-file-spec/README.md index d422a72a..db102d3f 100644 --- a/examples/6-multi-file-spec/README.md +++ b/examples/6-multi-file-spec/README.md @@ -19,7 +19,6 @@ npm start ## Try correct validation response with a multi-file spec - ``` curl -s -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{}'|jq { @@ -37,6 +36,6 @@ curl -s -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d add the required id and it returns correct ``` -curl -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{"id": 123}' -{} # note this test server returns empty object upon valid request -``` +curl -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{"id": 123}' +{} # note this test server returns empty object upon valid request +``` \ No newline at end of file diff --git a/examples/6-multi-file-spec/ems.yaml b/examples/6-multi-file-spec/ems.yaml index bcdc83f2..2a11f7a2 100644 --- a/examples/6-multi-file-spec/ems.yaml +++ b/examples/6-multi-file-spec/ems.yaml @@ -93,4 +93,4 @@ components: content: application/json: schema: - $ref: 'schemas/queryrequest.yaml' + $ref: 'schemas/queryrequest.yaml' \ No newline at end of file diff --git a/examples/6-multi-file-spec/schemas/queries.yaml b/examples/6-multi-file-spec/schemas/queries.yaml index 9b107d61..4ed219d8 100644 --- a/examples/6-multi-file-spec/schemas/queries.yaml +++ b/examples/6-multi-file-spec/schemas/queries.yaml @@ -1,3 +1,3 @@ type: array items: - $ref: 'queryrequest.yaml' + $ref: 'queryrequest.yaml' \ No newline at end of file diff --git a/examples/6-multi-file-spec/schemas/queryrequest.yaml b/examples/6-multi-file-spec/schemas/queryrequest.yaml index b792a96c..ebbab9d0 100644 --- a/examples/6-multi-file-spec/schemas/queryrequest.yaml +++ b/examples/6-multi-file-spec/schemas/queryrequest.yaml @@ -10,4 +10,4 @@ properties: type: string folder: type: string - nullable: true + nullable: true \ No newline at end of file diff --git a/examples/6-multi-file-spec/schemas/queryrequests.yaml b/examples/6-multi-file-spec/schemas/queryrequests.yaml index 58c1bfaa..8d97ec5c 100644 --- a/examples/6-multi-file-spec/schemas/queryrequests.yaml +++ b/examples/6-multi-file-spec/schemas/queryrequests.yaml @@ -3,4 +3,4 @@ properties: list: type: array items: - type: string + type: string \ No newline at end of file diff --git a/examples/7-response-date-serialization/api.yaml b/examples/7-response-date-serialization/api.yaml index 840d3b8c..1f3cbd98 100644 --- a/examples/7-response-date-serialization/api.yaml +++ b/examples/7-response-date-serialization/api.yaml @@ -34,7 +34,7 @@ paths: application/json: schema: $ref: '#/components/schemas/User' - + components: schemas: Date: @@ -43,7 +43,8 @@ components: User: type: object properties: - id: + id: type: number created_at: - $ref: '#/components/schemas/Date' + $ref: "#/components/schemas/Date" + \ No newline at end of file diff --git a/launch.json b/launch.json index 86b7ca51..ec4d7e8a 100644 --- a/launch.json +++ b/launch.json @@ -4,6 +4,7 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { "name": "Attach", "port": 9229, diff --git a/src/framework/ajv/factory.ts b/src/framework/ajv/factory.ts index 30b3d29c..9571bc5a 100644 --- a/src/framework/ajv/factory.ts +++ b/src/framework/ajv/factory.ts @@ -1,19 +1,19 @@ -import { Options } from 'ajv'; +import { Options } from "ajv"; import AjvDraft4 from 'ajv-draft-04'; import Ajv2020 from 'ajv/dist/2020'; -import { assertVersion } from '../openapi/assert.version'; -import { AjvInstance } from '../types'; +import { assertVersion } from "../openapi/assert.version"; +import { AjvInstance } from "../types"; export const factoryAjv = (version: string, options: Options): AjvInstance => { - const { minor } = assertVersion(version); + const { minor } = assertVersion(version) - let ajvInstance: AjvInstance; + let ajvInstance: AjvInstance if (minor === '0') { ajvInstance = new AjvDraft4(options); } else if (minor == '1') { ajvInstance = new Ajv2020(options); - + // Open API 3.1 has a custom "media-range" attribute defined in its schema, but the spec does not define it. "It's not really intended to be validated" // https://github.com/OAI/OpenAPI-Specification/issues/2714#issuecomment-923185689 // Since the schema is non-normative (https://github.com/OAI/OpenAPI-Specification/pull/3355#issuecomment-1915695294) we will only validate that it's a string @@ -21,5 +21,5 @@ export const factoryAjv = (version: string, options: Options): AjvInstance => { ajvInstance.addFormat('media-range', true); } - return ajvInstance; -}; + return ajvInstance +} \ No newline at end of file diff --git a/src/framework/ajv/index.ts b/src/framework/ajv/index.ts index 97e315d1..bb297080 100644 --- a/src/framework/ajv/index.ts +++ b/src/framework/ajv/index.ts @@ -1,5 +1,5 @@ import AjvDraft4 from 'ajv-draft-04'; -import Ajv2020 from 'ajv/dist/2020'; +import Ajv2020 from 'ajv/dist/2020' import { DataValidateFunction } from 'ajv/dist/types'; import ajvType from 'ajv/dist/vocabularies/jtd/type'; import addFormats from 'ajv-formats'; @@ -35,15 +35,15 @@ function createAjv( const ajv = factoryAjv(openApiSpec.openapi, { ...ajvOptions, - formats, - }); + formats + }) // Clean openApiSpec - traverse(openApiSpec, { allKeys: true }, ((schema) => { + traverse(openApiSpec, { allKeys: true }, (schema => { if ('x-stoplight' in schema) { - delete schema['x-stoplight']; + delete schema['x-stoplight'] } - })); + })) // Formats will overwrite existing validation, // so set in order of least->most important. @@ -116,15 +116,12 @@ function createAjv( compile: (sch, p, it) => { if (sch) { const validate: DataValidateFunction = (data, ctx) => { - if ( - options.removeAdditional == true || - options.removeAdditional == 'all' || - options.removeAdditional == 'failing' - ) { + if (options.removeAdditional == true || options.removeAdditional == "all" || options.removeAdditional == "failing") { // Remove readonly properties in request delete ctx.parentData[ctx.parentDataProperty]; return true; - } else { + } + else { const isValid = data == null; if (!isValid) { validate.errors = [ @@ -187,15 +184,12 @@ function createAjv( compile: (sch, p, it) => { if (sch) { const validate: DataValidateFunction = (data, ctx) => { - if ( - options.removeAdditional == true || - options.removeAdditional == 'all' || - options.removeAdditional == 'failing' - ) { + if (options.removeAdditional == true || options.removeAdditional == "all" || options.removeAdditional == "failing") { // Remove readonly properties in request delete ctx.parentData[ctx.parentDataProperty]; return true; - } else { + } + else { const isValid = data == null; if (!isValid) { validate.errors = [ @@ -204,7 +198,7 @@ function createAjv( instancePath: ctx.instancePath, schemaPath: it.schemaPath.str, message: `is write-only`, - params: { writeOnly: ctx.parentDataProperty }, + params: {writeOnly: ctx.parentDataProperty}, }, ]; } diff --git a/src/framework/ajv/options.ts b/src/framework/ajv/options.ts index bae60476..bde6859c 100644 --- a/src/framework/ajv/options.ts +++ b/src/framework/ajv/options.ts @@ -30,12 +30,9 @@ export class AjvOptions { } get request(): RequestValidatorOptions { - const { - allErrors, - allowUnknownQueryParameters, - coerceTypes, - removeAdditional, - } = this.options.validateRequests; + const { allErrors, allowUnknownQueryParameters, coerceTypes, removeAdditional } = < + ValidateRequestOpts + >this.options.validateRequests; return { ...this.baseOptions(), allErrors, @@ -50,8 +47,13 @@ export class AjvOptions { } private baseOptions(): Options { - const { coerceTypes, formats, validateFormats, serDes, ajvFormats } = - this.options; + const { + coerceTypes, + formats, + validateFormats, + serDes, + ajvFormats, + } = this.options; const serDesMap = {}; for (const serDesObject of serDes) { if (!serDesMap[serDesObject.format]) { diff --git a/src/framework/base.path.ts b/src/framework/base.path.ts index a4319a9f..1f56e92f 100644 --- a/src/framework/base.path.ts +++ b/src/framework/base.path.ts @@ -20,9 +20,9 @@ export class BasePath { let urlPath = this.findUrlPath(server.url); if (/:/.test(urlPath)) { // escape colons as (any at this point) do not signify express route params. - // this is an openapi base path, thus route params are wrapped in braces {}, + // this is an openapi base path, thus route params are wrapped in braces {}, // not prefixed by colon : (like express route params) - urlPath = urlPath.replace(':', '\\:'); + urlPath = urlPath.replace(':','\\:') } if (/{\w+}/.test(urlPath)) { // has variable that we need to check out @@ -47,7 +47,7 @@ export class BasePath { if (!servers) { return [new BasePath({ url: '' })]; } - return servers.map((server) => new BasePath(server)); + return servers.map(server => new BasePath(server)); } public hasVariables(): boolean { @@ -61,7 +61,7 @@ export class BasePath { // ignore variables that are not part of path params const allParams = Object.entries(this.variables).reduce((acc, v) => { const [key, value] = v; - const params = value.enum.map((e) => ({ + const params = value.enum.map(e => ({ [key]: e, })); acc.push(params); @@ -70,9 +70,7 @@ export class BasePath { const allParamCombos = cartesian(...allParams); // path-to-regexp v 8.x.x requires we escape the open and close parentheses `(`,`)` added a replace function to catch that use case. - const filteredExpressPath = this.expressPath - .replace(/[(]/g, '\\\\(') - .replace(/[)]/g, '\\\\)'); + const filteredExpressPath = this.expressPath.replace(/[(]/g, '\\\\(').replace(/[)]/g, '\\\\)'); const toPath = compile(filteredExpressPath); const paths = new Set(); for (const combo of allParamCombos) { @@ -83,12 +81,12 @@ export class BasePath { } private findUrlPath(u: string): string { - const findColonSlashSlash = (p) => { + const findColonSlashSlash = p => { const r = /:\/\//.exec(p); if (r) return r.index; return -1; }; - const findFirstSlash = (p) => { + const findFirstSlash = p => { const r = /\//.exec(p); if (r) return r.index; return -1; diff --git a/src/framework/base.serdes.ts b/src/framework/base.serdes.ts index 57eb2a8f..cd65ae48 100644 --- a/src/framework/base.serdes.ts +++ b/src/framework/base.serdes.ts @@ -1,23 +1,26 @@ import { SerDes, SerDesSingleton } from './types'; -export const dateTime: SerDesSingleton = new SerDesSingleton({ - format: 'date-time', +export const dateTime : SerDesSingleton = new SerDesSingleton({ + format : 'date-time', serialize: (d: Date) => { return d && d.toISOString(); }, deserialize: (s: string) => { return new Date(s); - }, + } }); -export const date: SerDesSingleton = new SerDesSingleton({ - format: 'date', +export const date : SerDesSingleton = new SerDesSingleton({ + format : 'date', serialize: (d: Date) => { return d && d.toISOString().split('T')[0]; }, deserialize: (s: string) => { return new Date(s); - }, + } }); -export const defaultSerDes: SerDes[] = [date.serializer, dateTime.serializer]; +export const defaultSerDes : SerDes[] = [ + date.serializer, + dateTime.serializer +]; diff --git a/src/framework/index.ts b/src/framework/index.ts index 5f9546cc..8fe2ceb9 100644 --- a/src/framework/index.ts +++ b/src/framework/index.ts @@ -101,9 +101,7 @@ export class OpenAPIFramework { return doc as Promise; } - private sortApiDocTags( - apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, - ): void { + private sortApiDocTags(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1): void { if (apiDoc && Array.isArray(apiDoc.tags)) { apiDoc.tags.sort((a, b): number => { return a.name < b.name ? -1 : 1; diff --git a/src/framework/json.ref.schema.ts b/src/framework/json.ref.schema.ts index e69de29b..8b137891 100644 --- a/src/framework/json.ref.schema.ts +++ b/src/framework/json.ref.schema.ts @@ -0,0 +1 @@ + diff --git a/src/framework/modded.express.mung.ts b/src/framework/modded.express.mung.ts index 6c774880..fc6c0a51 100644 --- a/src/framework/modded.express.mung.ts +++ b/src/framework/modded.express.mung.ts @@ -23,7 +23,7 @@ mung.onError = (err, req, res, next) => { }; mung.json = function json(fn, options) { - return function (req, res, next) { + return function(req, res, next) { let original = res.json; options = options || {}; let mungError = options.mungError; @@ -63,7 +63,7 @@ mung.json = function json(fn, options) { }; mung.jsonAsync = function json(fn, options) { - return function (req, res, next) { + return function(req, res, next) { let original = res.json; options = options || {}; let mungError = options.mungError; @@ -75,7 +75,7 @@ mung.jsonAsync = function json(fn, options) { if (!mungError && res.statusCode >= 400) return original.call(this, json); try { fn(json, req, res) - .then((json) => { + .then(json => { if (res.headersSent) return; // If null, then 204 No Content @@ -89,7 +89,7 @@ mung.jsonAsync = function json(fn, options) { return original.call(this, json); }) - .catch((e) => mung.onError(e, req, res, next)); + .catch(e => mung.onError(e, req, res, next)); } catch (e) { mung.onError(e, req, res, next); } @@ -103,7 +103,7 @@ mung.jsonAsync = function json(fn, options) { }; mung.headers = function headers(fn) { - return function (req, res, next) { + return function(req, res, next) { let original = res.end; function headers_hook() { res.end = original; @@ -129,9 +129,9 @@ mung.headers = function headers(fn) { }; mung.headersAsync = function headersAsync(fn) { - return function (req, res, next) { + return function(req, res, next) { let original = res.end; - let onError = (e) => { + let onError = e => { res.end = original; return mung.onError(e, req, res, next); }; @@ -146,7 +146,7 @@ mung.headersAsync = function headersAsync(fn) { if (res.headersSent) return; original.apply(this, args); }) - .catch((e) => onError(e)); + .catch(e => onError(e)); } catch (e) { onError(e); } @@ -158,7 +158,7 @@ mung.headersAsync = function headersAsync(fn) { }; mung.write = function write(fn, options: any = {}) { - return function (req, res, next) { + return function(req, res, next) { const original = res.write; const mungError = options.mungError; diff --git a/src/framework/openapi.context.ts b/src/framework/openapi.context.ts index c04f00cf..eab583d7 100644 --- a/src/framework/openapi.context.ts +++ b/src/framework/openapi.context.ts @@ -42,9 +42,7 @@ export class OpenApiContext { } public shouldIgnoreRoute(path: string) { - return typeof this.ignorePaths === 'function' - ? this.ignorePaths(path) - : this.ignorePaths?.test(path); + return typeof this.ignorePaths === 'function' ? this.ignorePaths(path) : this.ignorePaths?.test(path); } public routePair(route: string): RoutePair { diff --git a/src/framework/openapi.schema.validator.ts b/src/framework/openapi.schema.validator.ts index b2c1a559..3da4b035 100644 --- a/src/framework/openapi.schema.validator.ts +++ b/src/framework/openapi.schema.validator.ts @@ -1,4 +1,8 @@ -import { ErrorObject, Options, ValidateFunction } from 'ajv-draft-04'; +import { + ErrorObject, + Options, + ValidateFunction, +} from 'ajv-draft-04'; import addFormats from 'ajv-formats'; import { OpenAPIV3 } from './types.js'; import { factoryAjv } from './ajv/factory'; @@ -24,8 +28,8 @@ export class OpenAPISchemaValidator { options.validateSchema = false; } - const ajvInstance = factoryAjv(opts.version, options); - const schema = factorySchema(opts.version); + const ajvInstance = factoryAjv(opts.version, options) + const schema = factorySchema(opts.version) addFormats(ajvInstance, ['email', 'regex', 'uri', 'uri-reference']); diff --git a/src/framework/openapi.spec.loader.ts b/src/framework/openapi.spec.loader.ts index 06e76e36..7d0383df 100644 --- a/src/framework/openapi.spec.loader.ts +++ b/src/framework/openapi.spec.loader.ts @@ -78,16 +78,16 @@ export class OpenApiSpecLoader { ...(schema.parameters ?? []), ...(methods.parameters ?? []), ] - .map((param) => dereferenceParameter(apiDoc, param)) - .filter((param) => param.in === 'path') - .map((param) => param.name); + .map(param => dereferenceParameter(apiDoc, param)) + .filter(param => param.in === 'path') + .map(param => param.name); const openApiRoute = `${bp}${path}`; const expressRoute = `${openApiRoute}` .split(':') .map(toExpressParams) .join('\\:'); - + routes.push({ basePath: bp, expressRoute, @@ -111,7 +111,7 @@ export class OpenApiSpecLoader { apiDoc, basePaths, routes, - serial, + serial }; } @@ -121,7 +121,7 @@ export class OpenApiSpecLoader { // const pass1 = part.replace(/\{(\/)([^\*]+)(\*)}/g, '$1:$2$3'); //if wildcard path use new path-to-regex expected model - if (/[*]/g.test(part)) { + if(/[*]/g.test(part)){ // /v1/{path}* => /v1/*path) // /v1/{path}(*) => /v1/*path) const pass1 = part.replace(/\/{([^}]+)}\({0,1}(\*)\){0,1}/g, '/$2$1'); diff --git a/src/framework/openapi/assert.version.ts b/src/framework/openapi/assert.version.ts index 21d7a37c..f5c6e05e 100644 --- a/src/framework/openapi/assert.version.ts +++ b/src/framework/openapi/assert.version.ts @@ -1,19 +1,19 @@ /** * Asserts open api version - * + * * @param openApiVersion SemVer version * @returns destructured major and minor */ export const assertVersion = (openApiVersion: string) => { const [ok, major, minor] = /^(\d+)\.(\d+).(\d+)?$/.exec(openApiVersion); + + if (!ok) { + throw Error('Version missing from OpenAPI specification') + }; - if (!ok) { - throw Error('Version missing from OpenAPI specification'); - } - - if (major !== '3' || (minor !== '0' && minor !== '1')) { + if (major !== '3' || minor !== '0' && minor !== '1') { throw new Error('OpenAPI v3.0 or v3.1 specification version is required'); } - return { major, minor }; -}; + return { major, minor } +} \ No newline at end of file diff --git a/src/framework/openapi/factory.schema.ts b/src/framework/openapi/factory.schema.ts index 33ded3d6..2c78e1a0 100644 --- a/src/framework/openapi/factory.schema.ts +++ b/src/framework/openapi/factory.schema.ts @@ -1,4 +1,4 @@ -import { assertVersion } from './assert.version'; +import { assertVersion } from "./assert.version"; // https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v3.0/schema.json import * as openapi3Schema from '../openapi.v3.schema.json'; @@ -11,6 +11,6 @@ export const factorySchema = (version: string): Object => { if (minor === '0') { return openapi3Schema; } - - return openapi31Schema; -}; + + return openapi31Schema +} \ No newline at end of file diff --git a/src/framework/types.ts b/src/framework/types.ts index bd8d0762..0bf58026 100644 --- a/src/framework/types.ts +++ b/src/framework/types.ts @@ -7,7 +7,7 @@ import AjvDraft4 from 'ajv-draft-04'; import Ajv2020 from 'ajv/dist/2020'; export { OpenAPIFrameworkArgs }; -export type AjvInstance = AjvDraft4 | Ajv2020; +export type AjvInstance = AjvDraft4 | Ajv2020 export type BodySchema = | OpenAPIV3.ReferenceObject @@ -48,7 +48,7 @@ export interface Options extends ajv.Options { ajvFormats?: FormatsPluginOptions; } -export interface RequestValidatorOptions extends Options, ValidateRequestOpts {} +export interface RequestValidatorOptions extends Options, ValidateRequestOpts { } export type ValidateRequestOpts = { /** @@ -125,42 +125,32 @@ export class SerDesSingleton implements SerDes { serialize: param.serialize, }; } -} +}; export type SerDesMap = { - [format: string]: SerDes; + [format: string]: SerDes }; -type Primitive = undefined | null | boolean | string | number | Function; +type Primitive = undefined | null | boolean | string | number | Function -type Immutable = T extends Primitive - ? T - : T extends Array - ? ReadonlyArray - : T extends Map - ? ReadonlyMap - : Readonly; +type Immutable = + T extends Primitive ? T : + T extends Array ? ReadonlyArray : + T extends Map ? ReadonlyMap : Readonly -type DeepImmutable = T extends Primitive - ? T - : T extends Array - ? DeepImmutableArray - : T extends Map - ? DeepImmutableMap - : DeepImmutableObject; +type DeepImmutable = + T extends Primitive ? T : + T extends Array ? DeepImmutableArray : + T extends Map ? DeepImmutableMap : DeepImmutableObject interface DeepImmutableArray extends ReadonlyArray> {} -interface DeepImmutableMap - extends ReadonlyMap, DeepImmutable> {} +interface DeepImmutableMap extends ReadonlyMap, DeepImmutable> {} type DeepImmutableObject = { - readonly [K in keyof T]: DeepImmutable; -}; + readonly [K in keyof T]: DeepImmutable +} export interface OpenApiValidatorOpts { - apiSpec: - | DeepImmutable - | DeepImmutable - | string; + apiSpec: DeepImmutable | DeepImmutable | string; validateApiSpec?: boolean; validateResponses?: boolean | ValidateResponseOpts; validateRequests?: boolean | ValidateRequestOpts; @@ -215,18 +205,17 @@ export namespace OpenAPIV3 { } interface ComponentsV3_1 extends ComponentsObject { - pathItems?: { [path: string]: PathItemObject | ReferenceObject }; + pathItems?: { [path: string]: PathItemObject | ReferenceObject } } - export interface DocumentV3_1 - extends Omit { + export interface DocumentV3_1 extends Omit { openapi: `3.1.${string}`; paths?: DocumentV3['paths']; info: InfoObjectV3_1; components: ComponentsV3_1; webhooks: { - [name: string]: PathItemObject | ReferenceObject; - }; + [name: string]: PathItemObject | ReferenceObject + } } export interface InfoObject { @@ -310,7 +299,7 @@ export namespace OpenAPIV3 { in: string; } - export interface HeaderObject extends ParameterBaseObject {} + export interface HeaderObject extends ParameterBaseObject { } export interface ParameterBaseObject { description?: string; @@ -334,18 +323,14 @@ export namespace OpenAPIV3 { | 'integer'; export type ArraySchemaObjectType = 'array'; - export type SchemaObject = - | ArraySchemaObject - | NonArraySchemaObject - | CompositionSchemaObject; + export type SchemaObject = ArraySchemaObject | NonArraySchemaObject | CompositionSchemaObject; - export interface ArraySchemaObject - extends BaseSchemaObject { + export interface ArraySchemaObject extends BaseSchemaObject { items: ReferenceObject | SchemaObject; } - export interface NonArraySchemaObject - extends BaseSchemaObject {} + export interface NonArraySchemaObject extends BaseSchemaObject { + } export interface CompositionSchemaObject extends BaseSchemaObject { // JSON schema allowed properties, adjusted for OpenAPI diff --git a/src/middlewares/openapi.metadata.ts b/src/middlewares/openapi.metadata.ts index 587dabf1..ee576b0e 100644 --- a/src/middlewares/openapi.metadata.ts +++ b/src/middlewares/openapi.metadata.ts @@ -71,9 +71,7 @@ export function applyOpenApiMetadata( req: OpenApiRequest, useRequestUrl: boolean, ): OpenApiRequestMetadata { - const path = useRequestUrl - ? req.url.split('?')[0] - : req.originalUrl.split('?')[0]; + const path = useRequestUrl ? req.url.split('?')[0] : req.originalUrl.split('?')[0]; const method = req.method; const routeEntries = Object.entries(openApiContext.expressRouteMap); for (const [expressRoute, methods] of routeEntries) { diff --git a/src/middlewares/openapi.multipart.ts b/src/middlewares/openapi.multipart.ts index f1f52518..97a5fc47 100644 --- a/src/middlewares/openapi.multipart.ts +++ b/src/middlewares/openapi.multipart.ts @@ -42,7 +42,7 @@ export function multipart( // // This is a bit complex because the schema may be defined inline (easy) or via a $ref (complex) in which // case we must follow the $ref to check the type. - + if (req.files) { // to handle single and multiple file upload at the same time, let us this initialize this count variable // for example { "files": 5 } @@ -52,7 +52,7 @@ export function multipart( acc[curr] = (acc[curr] || 0) + 1; return acc; }, {}); - + // add file(s) to body Object.entries(count_by_fieldname).forEach( ([fieldname, count]: [string, number]) => { @@ -68,7 +68,7 @@ export function multipart( } }); }); - next(); + next() } catch (error) { next(error); } diff --git a/src/middlewares/openapi.request.validator.ts b/src/middlewares/openapi.request.validator.ts index 180ddebd..28303b4b 100644 --- a/src/middlewares/openapi.request.validator.ts +++ b/src/middlewares/openapi.request.validator.ts @@ -341,12 +341,8 @@ class Security { apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, schema: OperationObject, ): string[] { - const hasPathSecurity = schema.security - ? schema.security.length > 0 - : false; - const hasRootSecurity = apiDocs.security - ? apiDocs.security.length > 0 - : false; + const hasPathSecurity = schema.security ? schema.security.length > 0 : false; + const hasRootSecurity = apiDocs.security ? apiDocs.security.length > 0 : false; let usedSecuritySchema: SecurityRequirementObject[] = []; if (hasPathSecurity) { diff --git a/src/middlewares/openapi.security.ts b/src/middlewares/openapi.security.ts index 4accd534..64456183 100644 --- a/src/middlewares/openapi.security.ts +++ b/src/middlewares/openapi.security.ts @@ -24,31 +24,21 @@ interface SecurityHandlerResult { error?: string; } -function extractErrorsFromResults( - results: (SecurityHandlerResult | SecurityHandlerResult[])[], -) { - return results - .map((result) => { - if (Array.isArray(result)) { - return result.map((it) => it).filter((it) => !it.success); - } - return [result].filter((it) => !it.success); - }) - .flatMap((it) => [...it]); +function extractErrorsFromResults(results: (SecurityHandlerResult | SecurityHandlerResult[])[]) { + return results.map(result => { + if (Array.isArray(result)) { + return result.map(it => it).filter(it => !it.success); + } + return [result].filter(it => !it.success); + }).flatMap(it => [...it]); } function didAllSecurityRequirementsPass(results: SecurityHandlerResult[]) { - return results.every((it) => it.success); + return results.every(it => it.success); } -function didOneSchemaPassValidation( - results: (SecurityHandlerResult | SecurityHandlerResult[])[], -) { - return results.some((result) => - Array.isArray(result) - ? didAllSecurityRequirementsPass(result) - : result.success, - ); +function didOneSchemaPassValidation(results: (SecurityHandlerResult | SecurityHandlerResult[])[]) { + return results.some(result => Array.isArray(result) ? didAllSecurityRequirementsPass(result) : result.success); } export function security( @@ -245,13 +235,13 @@ class AuthValidator { // req.cookies will be `undefined` without `cookie-parser` middleware const authCookie = req.cookies?.[scheme.name] || req.signedCookies?.[scheme.name]; - + const type = scheme.scheme && scheme.scheme.toLowerCase(); if (type === 'bearer') { if (authHeader && !authHeader.includes('bearer')) { throw Error(`Authorization header with scheme 'Bearer' required`); } - + if (!authHeader && !authCookie) { if (scheme.in === 'cookie') { throw Error(`Cookie authentication required`); @@ -260,7 +250,7 @@ class AuthValidator { } } } - + if (type === 'basic') { if (!authHeader) { throw Error(`Authorization header required`); diff --git a/src/middlewares/parsers/body.parse.ts b/src/middlewares/parsers/body.parse.ts index 317efe3b..324aa313 100644 --- a/src/middlewares/parsers/body.parse.ts +++ b/src/middlewares/parsers/body.parse.ts @@ -7,7 +7,8 @@ import { } from '../../framework/types'; export class BodySchemaParser { - constructor() {} + constructor() { + } public parse( path: string, pathSchema: OpenAPIV3.OperationObject, @@ -43,11 +44,7 @@ export class BodySchemaParser { const equivalentContentTypes = contentType.equivalents(); for (const type of requestBodyTypes) { let openApiContentType = ContentType.fromString(type); - if ( - equivalentContentTypes.find( - (type2) => openApiContentType.normalize() === type2.normalize(), - ) - ) { + if (equivalentContentTypes.find((type2) => openApiContentType.normalize() === type2.normalize())) { content = requestBody.content[type]; break; } @@ -77,15 +74,13 @@ export class BodySchemaParser { if (!content) { // check if required is false, if so allow request when no content type is supplied const contentNotProvided = contentType.normalize() === 'not_provided'; - if ( - (contentType.normalize() === undefined || contentNotProvided) && - requestBody.required === false - ) { + if ((contentType.normalize() === undefined || contentNotProvided) && requestBody.required === false) { return {}; } - const msg = contentNotProvided - ? 'media type not specified' - : `unsupported media type ${contentType.normalize()}`; + const msg = + contentNotProvided + ? 'media type not specified' + : `unsupported media type ${contentType.normalize()}`; throw new UnsupportedMediaType({ path: path, message: msg }); } return content.schema ?? {}; diff --git a/src/middlewares/parsers/req.parameter.mutator.ts b/src/middlewares/parsers/req.parameter.mutator.ts index 73ca48a1..43da1f96 100644 --- a/src/middlewares/parsers/req.parameter.mutator.ts +++ b/src/middlewares/parsers/req.parameter.mutator.ts @@ -76,20 +76,10 @@ export class RequestParameterMutator { const i = req.originalUrl.indexOf('?'); const queryString = req.originalUrl.substr(i + 1); - if ( - parameter.in === 'query' && - !parameter.allowReserved && - !!parameter.explode - ) { - //} && !!parameter.explode) { + if (parameter.in === 'query' && !parameter.allowReserved && !!parameter.explode) { //} && !!parameter.explode) { this.validateReservedCharacters(name, rawQuery); } - if ( - parameter.in === 'query' && - !parameter.allowReserved && - !parameter.explode - ) { - //} && !!parameter.explode) { + if (parameter.in === 'query' && !parameter.allowReserved && !parameter.explode) { //} && !!parameter.explode) { this.validateReservedCharacters(name, rawQuery, true); } @@ -107,13 +97,7 @@ export class RequestParameterMutator { } else if (type === 'array' && !explode) { const delimiter = ARRAY_DELIMITER[parameter.style]; this.validateArrayDelimiter(delimiter, parameter); - this.parseJsonArrayAndMutateRequest( - req, - parameter.in, - name, - delimiter, - rawQuery, - ); + this.parseJsonArrayAndMutateRequest(req, parameter.in, name, delimiter, rawQuery); } else if (type === 'array' && explode) { this.explodeJsonArrayAndMutateRequest(req, parameter.in, name); } else if (style === 'form' && explode) { @@ -206,8 +190,8 @@ export class RequestParameterMutator { const properties = hasXOf ? xOfProperties(schema) : type === 'object' - ? Object.keys(schema.properties ?? {}) - : []; + ? Object.keys(schema.properties ?? {}) + : []; this.explodedJsonObjectAndMutateRequest( req, @@ -282,7 +266,7 @@ export class RequestParameterMutator { * filter=foo%20bar%20baz */ const field = REQUEST_FIELDS[$in]; - const rawValues = []; + const rawValues = [] if (['query'].includes($in)) { // perhaps split query from params rawValues.concat(rawQuery.get(name) ?? []); @@ -293,14 +277,11 @@ export class RequestParameterMutator { if (Array.isArray(req[field][name])) return; const value = req[field][name].split(delimiter); const rawValue = rawValues[i++]; - if (rawValue?.includes(delimiter)) { - // TODO add && !allowReserved to improve performance. When allowReserved is true, commas are common and we do not need to do this extra work + if (rawValue?.includes(delimiter)) { // TODO add && !allowReserved to improve performance. When allowReserved is true, commas are common and we do not need to do this extra work // Currently, rawValue is only populated for query params // if the raw value contains a delimiter, decode manually // parse the decode value and update req[field][name] - const manuallyDecodedValues = rawValue - .split(delimiter) - .map((v) => decodeURIComponent(v)); + const manuallyDecodedValues = rawValue.split(delimiter).map(v => decodeURIComponent(v)); req[field][name] = manuallyDecodedValues; } else { req[field][name] = value; diff --git a/src/middlewares/parsers/schema.parse.ts b/src/middlewares/parsers/schema.parse.ts index c23558ca..fb5d380c 100644 --- a/src/middlewares/parsers/schema.parse.ts +++ b/src/middlewares/parsers/schema.parse.ts @@ -19,10 +19,7 @@ export class ParametersSchemaParser { private _ajv: Ajv; private _apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; - constructor( - ajv: Ajv, - apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, - ) { + constructor(ajv: Ajv, apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { this._ajv = ajv; this._apiDocs = apiDocs; } diff --git a/src/middlewares/parsers/schema.preprocessor.ts b/src/middlewares/parsers/schema.preprocessor.ts index d56ac256..b6f756e8 100644 --- a/src/middlewares/parsers/schema.preprocessor.ts +++ b/src/middlewares/parsers/schema.preprocessor.ts @@ -44,24 +44,16 @@ class Node { } type SchemaObjectNode = Node; -function isParameterObject( - node: ParameterObject | ReferenceObject, -): node is ParameterObject { - return !(node as ReferenceObject).$ref; +function isParameterObject(node: ParameterObject | ReferenceObject): node is ParameterObject { + return !((node as ReferenceObject).$ref); } -function isReferenceObject( - node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject, -): node is ReferenceObject { - return !!(node as ReferenceObject).$ref; +function isReferenceObject(node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject): node is ReferenceObject { + return !!((node as ReferenceObject).$ref); } -function isArraySchemaObject( - node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject, -): node is ArraySchemaObject { - return !!(node as ArraySchemaObject).items; +function isArraySchemaObject(node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject): node is ArraySchemaObject { + return !!((node as ArraySchemaObject).items); } -function isNonArraySchemaObject( - node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject, -): node is NonArraySchemaObject { +function isNonArraySchemaObject(node: ArraySchemaObject | NonArraySchemaObject | ReferenceObject): node is NonArraySchemaObject { return !isArraySchemaObject(node) && !isReferenceObject(node); } @@ -169,7 +161,7 @@ export class SchemaPreprocessor { // Since OpenAPI 3.1, paths can be a #ref to reusable path items // The following line mutates the paths item to dereference the reference, so that we can process as a POJO, as we would if it wasn't a reference this.apiDoc.paths[p] = pathItem; - + for (const method of Object.keys(pathItem)) { if (httpMethods.has(method)) { const operation = pathItem[method]; @@ -179,8 +171,7 @@ export class SchemaPreprocessor { const node = new Root(operation, path); const requestBodies = this.extractRequestBodySchemaNodes(node); const responseBodies = this.extractResponseSchemaNodes(node); - const requestParameters = - this.extractRequestParameterSchemaNodes(node); + const requestParameters = this.extractRequestParameterSchemaNodes(node); requestBodySchemas.push(...requestBodies); responseSchemas.push(...responseBodies); @@ -253,10 +244,7 @@ export class SchemaPreprocessor { recurse(node, child, opts); }); } else if (schema.additionalProperties) { - const child = new Node(node, schema.additionalProperties, [ - ...node.path, - 'additionalProperties', - ]); + const child = new Node(node, schema.additionalProperties, [...node.path, 'additionalProperties']); recurse(node, child, opts); } }; @@ -312,7 +300,7 @@ export class SchemaPreprocessor { this.handleReadonly(pschema, nschema, options); this.handleWriteonly(pschema, nschema, options); this.processDiscriminator(pschema, nschema, options); - this.removeExamples(pschema, nschema, options); + this.removeExamples(pschema, nschema, options) } } } @@ -475,10 +463,10 @@ export class SchemaPreprocessor { ) { if (schema.type !== 'object') return; if (schema?.example) { - delete schema.example; + delete schema.example } if (schema?.examples) { - delete schema.examples; + delete schema.examples } } @@ -596,20 +584,21 @@ export class SchemaPreprocessor { private extractRequestParameterSchemaNodes( operationNode: Root, ): Root[] { + return (operationNode.schema.parameters ?? []).flatMap((node) => { const parameterObject = isParameterObject(node) ? node : undefined; if (!parameterObject?.schema) return []; - const schema = isNonArraySchemaObject(parameterObject.schema) - ? parameterObject.schema - : undefined; + const schema = isNonArraySchemaObject(parameterObject.schema) ? + parameterObject.schema : + undefined; if (!schema) return []; return new Root(schema, [ ...operationNode.path, 'parameters', parameterObject.name, - parameterObject.in, + parameterObject.in ]); }); } diff --git a/src/middlewares/util.ts b/src/middlewares/util.ts index 812504bb..991d4a80 100644 --- a/src/middlewares/util.ts +++ b/src/middlewares/util.ts @@ -5,14 +5,11 @@ import { ValidationError } from '../framework/types'; export class ContentType { public readonly mediaType: string = null; public readonly isWildCard: boolean; - public readonly parameters: { charset?: string; boundary?: string } & Record< - string, - string - > = {}; + public readonly parameters: { charset?: string, boundary?: string } & Record = {}; private constructor(contentType: string | null) { if (contentType) { const parameterRegExp = /;\s*([^=]+)=([^;]+)/g; - const paramMatches = contentType.matchAll(parameterRegExp); + const paramMatches = contentType.matchAll(parameterRegExp) if (paramMatches) { this.parameters = {}; for (let match of paramMatches) { @@ -25,7 +22,7 @@ export class ContentType { value = value.toLowerCase(); } this.parameters[key] = value; - } + }; } this.mediaType = contentType.split(';')[0].toLowerCase().trim(); this.isWildCard = RegExp(/^[a-z]+\/\*$/).test(contentType); @@ -47,9 +44,7 @@ export class ContentType { types.push(new ContentType(this.mediaType)); if (!this.parameters['charset']) { - types.push( - new ContentType(`${this.normalize(['charset'])}; charset=utf-8`), - ); + types.push(new ContentType(`${this.normalize(['charset'])}; charset=utf-8`)); } return types; } @@ -60,10 +55,11 @@ export class ContentType { .sort() .forEach((key) => { if (!excludeParams.includes(key)) { - parameters += `; ${key}=${this.parameters[key]}`; + parameters += `; ${key}=${this.parameters[key]}` } }); - if (this.mediaType) return this.mediaType + parameters; + if (this.mediaType) + return this.mediaType + parameters; } } @@ -134,10 +130,10 @@ export const findResponseContent = function ( expectedTypes: string[], ): string { const expectedTypesMap = new Map(); - for (let type of expectedTypes) { + for(let type of expectedTypes) { expectedTypesMap.set(ContentType.fromString(type).normalize(), type); } - + // if accepts are supplied, try to find a match, and use its validator for (const accept of accepts) { const act = ContentType.fromString(accept); @@ -171,6 +167,7 @@ export const findResponseContent = function ( export const zipObject = (keys, values) => keys.reduce((acc, key, idx) => { - acc[key] = values[idx]; - return acc; - }, {}); + acc[key] = values[idx] + return acc + }, {}) + diff --git a/src/openapi.validator.ts b/src/openapi.validator.ts index 083be35f..047c9a97 100644 --- a/src/openapi.validator.ts +++ b/src/openapi.validator.ts @@ -36,9 +36,9 @@ export { } from './framework/types'; interface MiddlewareContext { - context: OpenApiContext; - responseApiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; - error: any; + context: OpenApiContext, + responseApiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, + error: any, } export class OpenApiValidator { @@ -208,9 +208,7 @@ export class OpenApiValidator { middlewares.push(function responseMiddleware(req, res, next) { return pContext .then(({ responseApiDoc, context: { serial } }) => { - resmw = - resmw || - self.responseValidationMiddleware(responseApiDoc, serial); + resmw = resmw || self.responseValidationMiddleware(responseApiDoc, serial); return resmw(req, res, next); }) .catch(next); @@ -223,9 +221,7 @@ export class OpenApiValidator { middlewares.push(function operationHandlersMiddleware(req, res, next) { if (router) return router(req, res, next); return pContext - .then(({ context }) => - self.installOperationHandlers(req.baseUrl, context), - ) + .then(({context}) => self.installOperationHandlers(req.baseUrl, context)) .then((installedRouter) => (router = installedRouter)(req, res, next)) .catch(next); }); @@ -243,7 +239,7 @@ export class OpenApiValidator { } // install param on routes with paths - const uniqPathParams = [...new Set(pathParams)]; + const uniqPathParams = [...new Set(pathParams)] for (const p of uniqPathParams) { app.param( p, @@ -273,27 +269,21 @@ export class OpenApiValidator { return middlewares.applyOpenApiMetadata(context, responseApiDoc); } - private multipartMiddleware( - apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, - ) { + private multipartMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { return middlewares.multipart(apiDoc, { multerOpts: this.options.fileUploader, ajvOpts: this.ajvOpts.multipart, }); } - private securityMiddleware( - apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, - ) { + private securityMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { const securityHandlers = (( this.options.validateSecurity ))?.handlers; return middlewares.security(apiDoc, securityHandlers); } - private requestValidationMiddleware( - apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, - ) { + private requestValidationMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { const requestValidator = new middlewares.RequestValidator( apiDoc, this.ajvOpts.request, @@ -301,23 +291,17 @@ export class OpenApiValidator { return (req, res, next) => requestValidator.validate(req, res, next); } - private responseValidationMiddleware( - apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, - serial: number, - ) { + private responseValidationMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, serial: number) { return new middlewares.ResponseValidator( apiDoc, this.ajvOpts.response, // This has already been converted from boolean if required this.options.validateResponses as ValidateResponseOpts, - serial, + serial ).validate(); } - async installOperationHandlers( - baseUrl: string, - context: OpenApiContext, - ): Promise { + async installOperationHandlers(baseUrl: string, context: OpenApiContext): Promise { const router = express.Router({ mergeParams: true }); this.installPathParams(router, context); diff --git a/src/resolvers.ts b/src/resolvers.ts index e39a1150..18aba622 100644 --- a/src/resolvers.ts +++ b/src/resolvers.ts @@ -35,10 +35,7 @@ export function defaultResolver( tmpModules[modulePath] = require(modulePath); } - const handler = - tmpModules[modulePath][oId] || - tmpModules[modulePath].default[oId] || - tmpModules[modulePath].default; + const handler = tmpModules[modulePath][oId] || tmpModules[modulePath].default[oId] || tmpModules[modulePath].default; if (!handler) { throw Error( diff --git a/test/1022.spec.ts b/test/1022.spec.ts index 4d1afbe4..0c770fa9 100644 --- a/test/1022.spec.ts +++ b/test/1022.spec.ts @@ -157,5 +157,7 @@ describe(packageJson.name, () => { })); it('GET /some/test with wildcard should return 200', async () => - request(app).get(`/api/some/test/stuff`).expect(200)); + request(app) + .get(`/api/some/test/stuff`) + .expect(200)); }); diff --git a/test/356.campaign.spec.ts b/test/356.campaign.spec.ts index 57004cd5..fbe834db 100644 --- a/test/356.campaign.spec.ts +++ b/test/356.campaign.spec.ts @@ -1,4 +1,4 @@ -import * as path from 'path'; + import * as path from 'path'; import * as express from 'express'; import * as request from 'supertest'; import { createApp } from './common/app'; diff --git a/test/356.campaign.yaml b/test/356.campaign.yaml index cae88114..0f01a687 100644 --- a/test/356.campaign.yaml +++ b/test/356.campaign.yaml @@ -69,8 +69,8 @@ components: endDate: type: string format: date-time - example: - type: string + example: + type: string example: name: 'hi' - description: 'yo' + description: 'yo' \ No newline at end of file diff --git a/test/440.spec.ts b/test/440.spec.ts index d2b55939..50960245 100644 --- a/test/440.spec.ts +++ b/test/440.spec.ts @@ -45,19 +45,16 @@ describe(packageJson.name, () => { }, }, }; - app = await createApp( - { - apiSpec, - validateRequests: true, - validateResponses: true, - }, - 3005, - (app) => - app.use( - express - .Router() - .post(`/test/abc123`, (req, res) => res.status(200).json(req.body)), - ), + app = await createApp({ + apiSpec, + validateRequests: true, + validateResponses: true, + }, 3005, (app) => + app.use( + express + .Router() + .post(`/test/abc123`, (req, res) => res.status(200).json(req.body)), + ), ); }); diff --git a/test/577.spec.ts b/test/577.spec.ts index 49d0a139..a142d45a 100644 --- a/test/577.spec.ts +++ b/test/577.spec.ts @@ -13,7 +13,7 @@ describe('#577 - Exclude response validation that is not in api spec', () => { const app = await createApp(apiSpec); await request(app).get('/users').expect(200, 'some users'); await request(app).post('/users').expect(201, 'Created!'); - await request(app).get('/example').expect(200, 'Example indeed'); + await request(app).get ('/example').expect(200, 'Example indeed') app.server.close(); deepStrictEqual(apiSpec, createApiSpec()); @@ -34,15 +34,18 @@ async function createApp( }), ); app.get('/users', (req, res) => { - res.status(200).send('some users'); - }); + res.status(200).send('some users'); + } + ); app.post('/users', (req, res) => { - res.status(201).send('Created!'); - }); + res.status(201).send('Created!'); + } + ); app.get('/example', (req, res) => { - res.status(200).send('Example indeed'); - }); + res.status(200).send('Example indeed'); + } + ); await startServer(app, 3001); return app; diff --git a/test/699.spec.ts b/test/699.spec.ts index 7b85d31d..4e3399e2 100644 --- a/test/699.spec.ts +++ b/test/699.spec.ts @@ -10,18 +10,19 @@ const apiSpecPath = path.join('test', 'resources', '699.yaml'); class ObjectID { id: string; - constructor(id: string = '5fdefd13a6640bb5fb5fa925') { + constructor(id: string = "5fdefd13a6640bb5fb5fa925") { this.id = id; } toString() { return this.id; } + } class BadDate extends Date { public toISOString(): string { - return 'oh no a bad iso date'; + return "oh no a bad iso date"; } } @@ -34,16 +35,16 @@ describe('699', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true, + coerceTypes: true }, validateResponses: { - coerceTypes: true, + coerceTypes: true }, serDes: [ date, dateTime, { - format: 'mongo-objectid', + format: "mongo-objectid", deserialize: (s) => new ObjectID(s), serialize: (o) => o.toString(), }, @@ -54,9 +55,9 @@ describe('699', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'object') { - throw new Error('Should be deserialized to ObjectId object'); + throw new Error("Should be deserialized to ObjectId object"); } - let date = new Date('2020-12-20T07:28:19.213Z'); + let date = new Date("2020-12-20T07:28:19.213Z"); res.json({ id: req.params.id, creationDateTime: date, @@ -67,18 +68,11 @@ describe('699', () => { }); }); app.post([`${app.basePath}/users`], (req, res) => { - if ( - typeof req.body.history[0].modificationDate !== 'object' || - !(req.body.history[0].modificationDate instanceof Date) - ) { - throw new Error('Should be deserialized to Date object'); + if (typeof req.body.history[0].modificationDate !== 'object' || !(req.body.history[0].modificationDate instanceof Date)) { + throw new Error("Should be deserialized to Date object"); } - if ( - typeof req.body.historyWithoutRef[0].modificationDate !== - 'object' || - !(req.body.historyWithoutRef[0].modificationDate instanceof Date) - ) { - throw new Error('Should be deserialized to Date object'); + if (typeof req.body.historyWithoutRef[0].modificationDate !== 'object' || !(req.body.historyWithoutRef[0].modificationDate instanceof Date)) { + throw new Error("Should be deserialized to Date object"); } res.json(req.body); }); @@ -91,7 +85,7 @@ describe('699', () => { }, false, ); - return app; + return app }); after(() => { @@ -103,10 +97,8 @@ describe('699', () => { .get(`${app.basePath}/users/5fdefd13a6640bb5fb5fa925`) .expect(200) .then((r) => { - expect(r.body.history[0].modificationDate).to.equal('2020-12-20'); - expect(r.body.historyWithoutRef[0].modificationDate).to.equal( - '2020-12-20', - ); + expect(r.body.history[0].modificationDate).to.equal("2020-12-20"); + expect(r.body.historyWithoutRef[0].modificationDate).to.equal("2020-12-20"); })); it('should POST also works with deserialize on request then serialize en response', async () => @@ -123,10 +115,8 @@ describe('699', () => { .set('Content-Type', 'application/json') .expect(200) .then((r) => { - expect(r.body.history[0].modificationDate).to.equal('2020-12-20'); - expect(r.body.historyWithoutRef[0].modificationDate).to.equal( - '2020-12-20', - ); + expect(r.body.history[0].modificationDate).to.equal("2020-12-20"); + expect(r.body.historyWithoutRef[0].modificationDate).to.equal("2020-12-20"); })); it('should POST throw error on invalid schema Date', async () => @@ -142,9 +132,7 @@ describe('699', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/history/0/modificationDate must match format "date"', - ); + expect(r.body.message).to.equal('request/body/history/0/modificationDate must match format "date"'); })); it('should POST throw error on invalid schema Date', async () => @@ -160,12 +148,13 @@ describe('699', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/historyWithoutRef/0/modificationDate must match format "date"', - ); + expect(r.body.message).to.equal('request/body/historyWithoutRef/0/modificationDate must match format "date"'); })); + }); + + describe('699 serialize response components only', () => { let app = null; @@ -175,16 +164,16 @@ describe('699 serialize response components only', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true, + coerceTypes: true }, validateResponses: { - coerceTypes: true, + coerceTypes: true }, serDes: [ date.serializer, dateTime.serializer, { - format: 'mongo-objectid', + format: "mongo-objectid", serialize: (o) => o.toString(), }, ], @@ -194,9 +183,9 @@ describe('699 serialize response components only', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'string') { - throw new Error('Should be not be deserialized to ObjectId object'); + throw new Error("Should be not be deserialized to ObjectId object"); } - let date = new Date('2020-12-20T07:28:19.213Z'); + let date = new Date("2020-12-20T07:28:19.213Z"); let result = { id: new ObjectID(req.params.id), creationDateTime: date, @@ -208,20 +197,20 @@ describe('699 serialize response components only', () => { if (req.query.baddateresponse === 'functionNotExists') { result.history[0].modificationDate = new ObjectID(); result.historyWithoutRef[0].modificationDate = date; - } else if ( - req.query.baddateresponse === 'functionNotExistsWithoutRef' - ) { + } + else if (req.query.baddateresponse === 'functionNotExistsWithoutRef') { result.history[0].modificationDate = date; result.historyWithoutRef[0].modificationDate = new ObjectID(); - } else if (req.query.baddateresponse === 'functionBadFormat') { + } + else if (req.query.baddateresponse === 'functionBadFormat') { result.history[0].modificationDate = new BadDate(); result.historyWithoutRef[0].modificationDate = date; - } else if ( - req.query.baddateresponse === 'functionBadFormatWithoutRef' - ) { + } + else if (req.query.baddateresponse === 'functionBadFormatWithoutRef') { result.history[0].modificationDate = date; result.historyWithoutRef[0].modificationDate = new BadDate(); - } else { + } + else { result.history[0].modificationDate = date; result.historyWithoutRef[0].modificationDate = date; } @@ -229,24 +218,18 @@ describe('699 serialize response components only', () => { }); app.post([`${app.basePath}/users`], (req, res) => { if (typeof req.body.id !== 'string') { - throw new Error('Should NOT be deserialized to ObjectId object'); + throw new Error("Should NOT be deserialized to ObjectId object"); } if (typeof req.body.history[0].modificationDate !== 'string') { - throw new Error('Should NTO be deserialized to Date object'); + throw new Error("Should NTO be deserialized to Date object"); } - if ( - typeof req.body.historyWithoutRef[0].modificationDate !== 'string' - ) { - throw new Error('Should NOT be deserialized to Date object'); + if (typeof req.body.historyWithoutRef[0].modificationDate !== 'string') { + throw new Error("Should NOT be deserialized to Date object"); } req.body.id = new ObjectID(req.body.id); req.body.creationDateTime = new Date(req.body.creationDateTime); - req.body.history[0].modificationDate = new Date( - req.body.history[0].modificationDate, - ); - req.body.historyWithoutRef[0].modificationDate = new Date( - req.body.historyWithoutRef[0].modificationDate, - ); + req.body.history[0].modificationDate = new Date(req.body.history[0].modificationDate); + req.body.historyWithoutRef[0].modificationDate = new Date(req.body.historyWithoutRef[0].modificationDate); // We let creationDate et al as String and it should also work (either in Date Object ou String 'date' format) res.json(req.body); }); @@ -259,7 +242,7 @@ describe('699 serialize response components only', () => { }, false, ); - return app; + return app }); after(() => { @@ -273,11 +256,9 @@ describe('699 serialize response components only', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); - expect(r.body.history[0].modificationDate).to.equal('2020-12-20'); - expect(r.body.historyWithoutRef[0].modificationDate).to.equal( - '2020-12-20', - ); + expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); + expect(r.body.history[0].modificationDate).to.equal("2020-12-20"); + expect(r.body.historyWithoutRef[0].modificationDate).to.equal("2020-12-20"); })); it('should POST also works with deserialize on request then serialize en response', async () => @@ -293,10 +274,8 @@ describe('699 serialize response components only', () => { .set('Content-Type', 'application/json') .expect(200) .then((r) => { - expect(r.body.history[0].modificationDate).to.equal('2020-12-20'); - expect(r.body.historyWithoutRef[0].modificationDate).to.equal( - '2020-12-20', - ); + expect(r.body.history[0].modificationDate).to.equal("2020-12-20"); + expect(r.body.historyWithoutRef[0].modificationDate).to.equal("2020-12-20"); })); it('should POST throw error on invalid schema Date', async () => @@ -312,9 +291,7 @@ describe('699 serialize response components only', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/history/0/modificationDate must match format "date"', - ); + expect(r.body.message).to.equal('request/body/history/0/modificationDate must match format "date"'); })); it('should POST throw error on invalid schema Date', async () => @@ -330,9 +307,7 @@ describe('699 serialize response components only', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/historyWithoutRef/0/modificationDate must match format "date"', - ); + expect(r.body.message).to.equal('request/body/historyWithoutRef/0/modificationDate must match format "date"'); })); it('should throw error 500 on invalid object type instead of Date expected', async () => @@ -371,4 +346,7 @@ describe('699 serialize response components only', () => { })); */ + }); + + diff --git a/test/821.spec.ts b/test/821.spec.ts index 4e2fbbfc..5b9bc75d 100644 --- a/test/821.spec.ts +++ b/test/821.spec.ts @@ -7,22 +7,24 @@ import { startServer } from './common/app.common'; import { deepStrictEqual } from 'assert'; import * as path from 'path'; + const apiSpecPath = path.join('test', 'resources', '699.yaml'); -const date = new Date(); +const date = new Date() describe('issue #821 - serialization inside addiotionalProperties', () => { it('serializa both outer and inner date in addiotionalProperties', async () => { + const app = await createApp(apiSpecPath); - await request(app) - .get('/test') - .expect(200, { + await request(app).get('/test').expect(200, + { outer_date: date.toISOString(), other_info: { something: { - inner_date: date.toISOString(), - }, - }, - }); + inner_date: date.toISOString() + } + } + } + ); app.server!.close(); }); }); @@ -44,11 +46,12 @@ async function createApp( outer_date: date, other_info: { something: { - inner_date: date, - }, - }, - }); - }); + inner_date: date + } + } + }) + + }) app.use((err, req, res, next) => { console.error(err); // dump error to console for debug @@ -61,3 +64,5 @@ async function createApp( await startServer(app, 3001); return app; } + + diff --git a/test/ajv.resolves.more.than.one.schema.spec.ts b/test/ajv.resolves.more.than.one.schema.spec.ts index 550520cc..a61c6d7e 100644 --- a/test/ajv.resolves.more.than.one.schema.spec.ts +++ b/test/ajv.resolves.more.than.one.schema.spec.ts @@ -12,17 +12,15 @@ describe('AJV: reference resolves to more than one schema', () => { const app = await createApp(apiSpec); - await request(app) - .get('/bear') - .expect((res) => { - if (res.text.includes('resolves to more than one schema')) { - throw new Error('AJV not processing x-stoplight property correctly.'); - } + await request(app).get('/bear').expect(res => { + if (res.text.includes('resolves to more than one schema')) { + throw new Error('AJV not processing x-stoplight property correctly.') + } - if (!res.text.includes('Black Bear')) { - throw new Error(); - } - }); + if (!res.text.includes('Black Bear')) { + throw new Error() + } + }) app.server.close(); @@ -48,8 +46,8 @@ async function createApp( ); app.use((err, req, res, next) => { - res.status(500).send(err.stack); - }); + res.status(500).send(err.stack) + }) await startServer(app, 3001); return app; @@ -67,15 +65,15 @@ function createApiSpec() { parameters: [], get: { responses: { - '200': { + '200': { description: 'OK', content: { 'application/json': { schema: { - $ref: '#/components/schemas/Bear', - }, - }, - }, + $ref: '#/components/schemas/Bear' + } + } + } }, }, }, @@ -86,15 +84,15 @@ function createApiSpec() { Bear: { title: 'Bear', 'x-stoplight': { - id: 'ug68n9uynqll0', + id: 'ug68n9uynqll0' }, properties: { type: { - type: 'string', - }, - }, - }, - }, - }, + type: 'string' + } + } + } + } + } }; } diff --git a/test/common/app.common.ts b/test/common/app.common.ts index 355f23fd..523948e8 100644 --- a/test/common/app.common.ts +++ b/test/common/app.common.ts @@ -17,22 +17,22 @@ export function routes(app) { const basePath = app.basePath; const router1 = express .Router() - .post('/', function (req: Request, res: Response): void { + .post('/', function(req: Request, res: Response): void { res.json({ name: `${req.method}: /router_1`, }); }) - .get('/', function (req: Request, res: Response): void { + .get('/', function(req: Request, res: Response): void { res.json({ name: `${req.method}: /router_1`, }); }) - .get('/:id', function (req: Request, res: Response): void { + .get('/:id', function(req: Request, res: Response): void { res.json({ name: `${req.method}: /router_1/${req.params.id}`, }); }) - .get('/:id/best/:bid', function (req: Request, res: Response): void { + .get('/:id/best/:bid', function(req: Request, res: Response): void { res.json({ name: `${req.method}: /router_1/${req.params.id}/best/${req.params.bid}`, }); @@ -40,7 +40,7 @@ export function routes(app) { app.use(`${basePath}/router_1`, router1); - app.get(`${basePath}/pets`, function (req: Request, res: Response): void { + app.get(`${basePath}/pets`, function(req: Request, res: Response): void { res.json({ test: 'hi', body: req.body, @@ -48,7 +48,7 @@ export function routes(app) { }); }); - app.post(`${basePath}/pets`, function (req: Request, res: Response): void { + app.post(`${basePath}/pets`, function(req: Request, res: Response): void { res.json({ body: req.body, query: req.query, @@ -56,48 +56,48 @@ export function routes(app) { }); }); - app.get(`${basePath}/pets/:id`, function (req: Request, res: Response): void { + app.get(`${basePath}/pets/:id`, function(req: Request, res: Response): void { res.json({ id: req.params.id, }); }); - app.get( - `${basePath}/pets/:id/attributes`, - function (req: Request, res: Response): void { - res.json({ - id: req.params.id, - }); - }, - ); + app.get(`${basePath}/pets/:id/attributes`, function( + req: Request, + res: Response, + ): void { + res.json({ + id: req.params.id, + }); + }); - app.get( - `${basePath}/pets/:id/attributes/:attribute_id`, - function (req: Request, res: Response): void { - res.json({ - id: req.params.id, - attribute_id: req.params.attribute_id, - }); - }, - ); + app.get(`${basePath}/pets/:id/attributes/:attribute_id`, function( + req: Request, + res: Response, + ): void { + res.json({ + id: req.params.id, + attribute_id: req.params.attribute_id, + }); + }); - app.post( - `${basePath}/route_defined_in_express_not_openapi`, - function (req: Request, res: Response): void { - res.json({ - id: req.params.id, - }); - }, - ); + app.post(`${basePath}/route_defined_in_express_not_openapi`, function( + req: Request, + res: Response, + ): void { + res.json({ + id: req.params.id, + }); + }); - app.get( - '/not_under_an_openapi_basepath', - function (req: Request, res: Response): void { - res.json({ - id: '/not_under_an_openapi_basepath', - }); - }, - ); + app.get('/not_under_an_openapi_basepath', function( + req: Request, + res: Response, + ): void { + res.json({ + id: '/not_under_an_openapi_basepath', + }); + }); // app.post('/v1/pets/:id/photos', function(req: Request, res: Response): void { // // req.file is the `avatar` file @@ -108,7 +108,7 @@ export function routes(app) { // metadata: req.body.metadata, // }); // }); - app.post('/v1/pets_charset', function (req: Request, res: Response): void { + app.post('/v1/pets_charset', function(req: Request, res: Response): void { // req.file is the `avatar` file // req.body will hold the text fields, if there were any res.json({ @@ -117,16 +117,13 @@ export function routes(app) { }); }); - app.post( - '/v1/pets_content_types', - function (req: Request, res: Response): void { - // req.file is the `avatar` file - // req.body will hold the text fields, if there were any - res.json({ - ...req.body, - contentType: req.headers['content-type'], - id: 'new-id', - }); - }, - ); + app.post('/v1/pets_content_types', function(req: Request, res: Response): void { + // req.file is the `avatar` file + // req.body will hold the text fields, if there were any + res.json({ + ...req.body, + contentType: req.headers['content-type'], + id: 'new-id', + }); + }); } diff --git a/test/common/app.ts b/test/common/app.ts index c7ade663..e9adf6e7 100644 --- a/test/common/app.ts +++ b/test/common/app.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import * as cookieParser from 'cookie-parser'; import * as logger from 'morgan'; -import * as OpenApiValidator from '../../src'; +import * as OpenApiValidator from '../../src'; import { startServer, routes } from './app.common'; import { OpenApiValidatorOpts } from '../../src/framework/types'; diff --git a/test/common/test.yaml b/test/common/test.yaml index d7ca5323..4d952dd9 100644 --- a/test/common/test.yaml +++ b/test/common/test.yaml @@ -230,4 +230,4 @@ components: ApiKeyAuth: type: apiKey in: header - name: X-API-Key + name: X-API-Key \ No newline at end of file diff --git a/test/component.params.spec.ts b/test/component.params.spec.ts index d0ffad4e..0a4c83ba 100644 --- a/test/component.params.spec.ts +++ b/test/component.params.spec.ts @@ -11,7 +11,7 @@ describe(packageJson.name, () => { before(async () => { // Set up the express app const apiSpec = path.join('test', 'resources', 'component.params.yaml'); - app = await createApp({ apiSpec }, 3005, (app) => + app = await createApp({ apiSpec }, 3005, app => app.use( `/`, express @@ -30,7 +30,7 @@ describe(packageJson.name, () => { request(app) .get(`/api/v1/meeting/${id}`) .expect(200) - .then((r) => { + .then(r => { expect(r.body.id).to.equal(id); }); }); diff --git a/test/content.type.spec.ts b/test/content.type.spec.ts index 9f55025e..9db4fbbf 100644 --- a/test/content.type.spec.ts +++ b/test/content.type.spec.ts @@ -38,7 +38,10 @@ describe('contentType', () => { }); it('should match media type if charset is specified in accepts, but charset not defined in schema', async () => { - const expectedTypes = ['application/json', 'application/xml']; + const expectedTypes = [ + 'application/json', + 'application/xml', + ]; const accepts = ['application/json; charset=utf-8']; const contentType = findResponseContent(accepts, expectedTypes); diff --git a/test/datetime.validation.spec.ts b/test/datetime.validation.spec.ts index 685643d7..5538ec7b 100644 --- a/test/datetime.validation.spec.ts +++ b/test/datetime.validation.spec.ts @@ -1,22 +1,22 @@ import * as path from 'path'; -import { expect } from 'chai'; +import {expect} from 'chai'; import * as request from 'supertest'; -import { createApp } from './common/app'; +import {createApp} from './common/app'; -describe('datetime.validation', () => { +describe("datetime.validation", () => { let app = null; - async function setupServer(validateFormats?: false | 'full' | 'fast') { + async function setupServer(validateFormats?: false | "full" | "fast") { // Set up the express app const apiSpec = path.join('test', 'resources', 'datetime.validation.yaml'); app = await createApp( { apiSpec, validateResponses: true, - validateFormats, + validateFormats }, 3005, - (app) => { + app => { // Define new coercion routes app.post(`${app.basePath}/date-time-validation`, (req, res) => { res.json(req.body); @@ -32,10 +32,11 @@ describe('datetime.validation', () => { afterEach(async () => { if (app) { - await new Promise((resolve) => app.server.close(resolve)); + await new Promise(resolve => app.server.close(resolve)); } }); + it('should return 200 if testDateTimeProperty is provided with invalid, but correctly formatted date time and default validation is enabled (past compatibility)', async () => { await setupServer(); await request(app) @@ -44,8 +45,8 @@ describe('datetime.validation', () => { testDateTimeProperty: '2000-13-03T12:13:14Z', }) .expect(200) - .then((r) => { - const { body } = r; + .then(r => { + const {body} = r; expect(body).to.have.property('testDateTimeProperty'); }); }); @@ -68,28 +69,28 @@ describe('datetime.validation', () => { testDateTimeProperty: 'blah-blah', }) .expect(200) - .then((r) => { - const { body } = r; + .then(r => { + const {body} = r; expect(body).to.have.property('testDateTimeProperty'); }); }); it('should return 200 if testDateTimeProperty is provided with valid date time and full validation enabled', async () => { - await setupServer('full'); + await setupServer("full"); await request(app) .post(`${app.basePath}/date-time-validation`) .send({ testDateTimeProperty: '2000-02-03T12:13:14Z', }) .expect(200) - .then((r) => { - const { body } = r; + .then(r => { + const {body} = r; expect(body).to.have.property('testDateTimeProperty'); }); }); it('should return 400 if testDateTimeProperty is provided with invalid date time and full validation enabled', async () => { - await setupServer('full'); + await setupServer("full"); await request(app) .post(`${app.basePath}/date-time-validation`) .send({ diff --git a/test/default-export.spec.ts b/test/default-export.spec.ts index ef60789c..cacff56d 100644 --- a/test/default-export.spec.ts +++ b/test/default-export.spec.ts @@ -13,8 +13,8 @@ const schema = { get: { operationId: 'anything', 'x-eov-operation-handler': 'controller-with-default', - responses: { 200: { description: 'home api' } }, - }, + responses: { 200: { description: 'home api' } } + } }, }, } as const; diff --git a/test/default.export.fn.spec.ts b/test/default.export.fn.spec.ts index 52bc036a..e01a356e 100644 --- a/test/default.export.fn.spec.ts +++ b/test/default.export.fn.spec.ts @@ -3,7 +3,7 @@ import * as OpenApiValidator from '../src'; import { expect } from 'chai'; import * as request from 'supertest'; import * as path from 'path'; -import { OpenAPIV3 } from '../src/framework/types'; +import {OpenAPIV3} from "../src/framework/types"; describe('default export resolver', () => { let server = null; @@ -21,8 +21,8 @@ describe('default export resolver', () => { operationId: 'test#get', // @ts-ignore 'x-eov-operation-handler': 'routes/default-export-fn', - responses: { 200: { description: 'homepage' } }, - }, + responses: { 200: { description: 'homepage' } } + } }, }, }, @@ -41,7 +41,7 @@ describe('default export resolver', () => { .get(`/`) .expect(200) .then((r) => { - expect(r.body).to.have.property('message').that.equals('It Works!'); + expect(r.body).to.have.property('message').that.equals("It Works!"); }); }); }); diff --git a/test/escaped.characters.in.ref.path.spec.ts b/test/escaped.characters.in.ref.path.spec.ts index 30c37d44..2a2ec4e5 100644 --- a/test/escaped.characters.in.ref.path.spec.ts +++ b/test/escaped.characters.in.ref.path.spec.ts @@ -8,35 +8,27 @@ describe('when escaped characters are in path', () => { before(async () => { // Set up the express app - const apiSpec = path.join( - 'test', - 'resources', - 'escaped.characters.in.path.yaml', - ); - app = await createApp( - { apiSpec, $refParser: { mode: 'dereference' } }, - 3005, - (app) => { - app.use( - `${app.basePath}`, - express.Router().post(`/auth/login`, (req, res) => - res.json({ - token: 'SOME_JWT_TOKEN', - user: { - fullName: 'Eric Cartman', - role: 'admin', - }, - }), - ), - ); - app.use( - `${app.basePath}`, - express - .Router() - .post(`/auth/register`, (req, res) => res.status(200).end()), - ); - }, - ); + const apiSpec = path.join('test', 'resources', 'escaped.characters.in.path.yaml'); + app = await createApp({ apiSpec, $refParser: {mode: 'dereference'} }, 3005, app => { + app.use( + `${app.basePath}`, + express + .Router() + .post(`/auth/login`, (req, res) => res.json({ + 'token': 'SOME_JWT_TOKEN', + 'user': { + 'fullName': 'Eric Cartman', + 'role': 'admin', + }, + })), + ); + app.use( + `${app.basePath}`, + express + .Router() + .post(`/auth/register`, (req, res) => res.status(200).end()), + ); + }); }); after(() => { @@ -52,7 +44,8 @@ describe('when escaped characters are in path', () => { password: '123456', fullName: 'Eric Cartman', }) - .expect(200)); + .expect(200), + ); it('should be able to use an endpoint with some nested paths $ref 2', async () => request(app) @@ -61,5 +54,7 @@ describe('when escaped characters are in path', () => { email: 'jy95@perdu.com', password: '123456', }) - .expect(200)); + .expect(200), + ); + }); diff --git a/test/headers.2.spec.ts b/test/headers.2.spec.ts index 81f9b582..d67c0afa 100644 --- a/test/headers.2.spec.ts +++ b/test/headers.2.spec.ts @@ -54,7 +54,9 @@ describe(packageJson.name, () => { .expect(400) .then((r) => { const e = r.body; - expect(e.message).to.contain('must NOT have more than 255 characters'); + expect(e.message).to.contain( + 'must NOT have more than 255 characters', + ); }); }); diff --git a/test/headers.spec.ts b/test/headers.spec.ts index 79959ce6..7c3ec860 100644 --- a/test/headers.spec.ts +++ b/test/headers.spec.ts @@ -71,7 +71,7 @@ describe(packageJson.name, () => { }) .expect(200)); - it('should succeed in sending a content-type: "application/json; version=1" in multiple ways', async () => { + it('should succeed in sending a content-type: "application/json; version=1" in multiple ways', async () =>{ await request(app) .post(`${app.basePath}/pets_content_types`) .set('Content-Type', 'application/json; version=1') @@ -82,7 +82,7 @@ describe(packageJson.name, () => { }) .expect(200) .expect((res) => { - expect(res.body.contentType).to.equal('application/json; version=1'); + expect(res.body.contentType).to.equal('application/json; version=1') }); await request(app) @@ -95,10 +95,10 @@ describe(packageJson.name, () => { }) .expect(200) .expect((res) => { - expect(res.body.contentType).to.equal('application/json;version=1'); + expect(res.body.contentType).to.equal('application/json;version=1') }); }); - + it('should throw a 415 error for unsupported "application/json; version=2" content type', async () => request(app) .post(`${app.basePath}/pets_content_types`) @@ -121,9 +121,9 @@ describe(packageJson.name, () => { }) .expect(200) .expect((res) => { - expect(res.body.contentType).to.equal('application/json;version=1'); + expect(res.body.contentType).to.equal('application/json;version=1') }); - + await request(app) .post(`${app.basePath}/pets_content_types`) .set('Content-Type', 'application/json; version=3') diff --git a/test/httperror.spec.ts b/test/httperror.spec.ts index 45b8872d..91ed8475 100644 --- a/test/httperror.spec.ts +++ b/test/httperror.spec.ts @@ -86,9 +86,7 @@ describe(packageJson.name, () => { path: '/method_not_allowed', message: 'POST method not allowed', }; - expect(new error.MethodNotAllowed(err)).to.be.an.instanceof( - error.MethodNotAllowed, - ); + expect(new error.MethodNotAllowed(err)).to.be.an.instanceof(error.MethodNotAllowed); expect( HttpError.create({ status: 405, diff --git a/test/ignore.paths.spec.ts b/test/ignore.paths.spec.ts index 6ff49924..b795b7a3 100644 --- a/test/ignore.paths.spec.ts +++ b/test/ignore.paths.spec.ts @@ -12,7 +12,7 @@ describe('ignorePaths as RegExp', () => { app = await createApp( { apiSpec, ignorePaths: /.*\/hippies$/ }, 3005, - (app) => { + app => { app.all('/v1/hippies', (req, res) => { res.json([ { id: 1, name: 'farah' }, @@ -74,7 +74,7 @@ describe('ignorePaths as RegExp', () => { return request(app) .get(`${basePath}/pets/${id}`) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].path).contains('id'); expect(e[0].message).equals('must be integer'); @@ -85,7 +85,7 @@ describe('ignorePaths as RegExp', () => { request(app) .get(`${basePath}/route_defined_in_openapi_only`) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].message).to.equal("must have required property 'id'"); })); @@ -95,7 +95,7 @@ describe('ignorePaths as RegExp', () => { .get(`${basePath}/route_defined_in_openapi_only`) .query({ id: 123 }) .expect(404) - .then((r) => { + .then(r => { const e = r.body; // There is no route defined by express, hence the validator verifies parameters, // then it fails over to the express error handler. In this case returns empty @@ -114,7 +114,7 @@ describe('ignorePaths as Function', () => { app = await createApp( { apiSpec, ignorePaths: (path) => path.endsWith('/hippies') }, 3005, - (app) => { + app => { app.all('/v1/hippies', (req, res) => { res.json([ { id: 1, name: 'farah' }, @@ -173,7 +173,7 @@ describe('ignorePaths as Function', () => { return request(app) .get(`${basePath}/pets/${id}`) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].path).contains('id'); expect(e[0].message).equals('must be integer'); @@ -184,7 +184,7 @@ describe('ignorePaths as Function', () => { request(app) .get(`${basePath}/route_defined_in_openapi_only`) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].message).to.equal("must have required property 'id'"); })); @@ -194,7 +194,7 @@ describe('ignorePaths as Function', () => { .get(`${basePath}/route_defined_in_openapi_only`) .query({ id: 123 }) .expect(404) - .then((r) => { + .then(r => { const e = r.body; // There is no route defined by express, hence the validator verifies parameters, // then it fails over to the express error handler. In this case returns empty diff --git a/test/multi.spec.spec.ts b/test/multi.spec.spec.ts index c93f9224..21f8d6ab 100644 --- a/test/multi.spec.spec.ts +++ b/test/multi.spec.spec.ts @@ -33,7 +33,7 @@ describe('multi-spec', () => { function createServer() { const express = require('express'); - const path = require('path'); + const path = require('path'); const http = require('http'); const OpenApiValidator = require('../src'); diff --git a/test/multipart.disabled.spec.ts b/test/multipart.disabled.spec.ts index 45359836..2b715fd6 100644 --- a/test/multipart.disabled.spec.ts +++ b/test/multipart.disabled.spec.ts @@ -39,8 +39,10 @@ describe(packageJson.name, () => { .set('Content-Type', 'multipart/form-data') .set('Accept', 'application/json') .expect(400) - .then((e) => { - expect(e.body).has.property('errors').with.length(2); + .then(e => { + expect(e.body) + .has.property('errors') + .with.length(2); expect(e.body.errors[0]) .has.property('message') .equal("must have required property 'file'"); @@ -91,8 +93,10 @@ describe(packageJson.name, () => { .set('Content-Type', 'application/json') .expect('Content-Type', /json/) .expect(415) - .then((r) => { - expect(r.body).has.property('errors').with.length(1); + .then(r => { + expect(r.body) + .has.property('errors') + .with.length(1); expect(r.body.errors[0]) .has.property('message') .equal('unsupported media type application/json'); @@ -107,7 +111,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('number'); diff --git a/test/multipart.spec.ts b/test/multipart.spec.ts index 51352822..807e3759 100644 --- a/test/multipart.spec.ts +++ b/test/multipart.spec.ts @@ -129,8 +129,8 @@ describe('a multipart request', () => { it('should validate multipart file and metadata', async () => { const array_with_objects = JSON.stringify([ { - foo: 'bar', - }, + foo: 'bar' + } ]); await request(app) @@ -169,13 +169,16 @@ describe('when request does not use parsers', () => { (app) => app.use( `${app.basePath}`, - express.Router().post(`/sample_7`, (req, res) => res.json('ok')), + express + .Router() + .post(`/sample_7`, (req, res) => res.json('ok')), ), false, false, ); }); + it('should validate that endpoint exists', async () => { await request(app) .post(`${app.basePath}/sample_7`) diff --git a/test/nested.routes.spec.ts b/test/nested.routes.spec.ts index 243d7a5b..8bb8b81e 100644 --- a/test/nested.routes.spec.ts +++ b/test/nested.routes.spec.ts @@ -10,28 +10,31 @@ describe(packageJson.name, () => { before(async () => { // Set up the express app - const apiSpec = path.join('test', 'resources', 'nested.routes.yaml'); + const apiSpec = path.join( + 'test', + 'resources', + 'nested.routes.yaml', + ); const apiRoute = express.Router(), nestedRoute = express.Router(); - app = await createApp( - { - apiSpec, - validateRequests: true, - validateResponses: true, + app = await createApp({ + apiSpec, + validateRequests: true, + validateResponses: true, }, 3005, - (app) => { + app =>{ app.use(`${app.basePath}`, apiRoute); apiRoute.use('/api-path', nestedRoute); nestedRoute.get('/pets', (_req, res) => { const json = [ { name: 'test', - tag: 'tag', - }, + tag: 'tag' + } ]; return res.json(json); - }); + }) }, true, ); @@ -48,8 +51,6 @@ describe(packageJson.name, () => { .expect(500) .then((r: any) => { const e = r.body; - expect(e.message).to.contain( - "/response/0 must have required property 'id'", - ); + expect(e.message).to.contain("/response/0 must have required property 'id'"); })); }); diff --git a/test/one.of.spec.ts b/test/one.of.spec.ts index 1a405a52..15c652d2 100644 --- a/test/one.of.spec.ts +++ b/test/one.of.spec.ts @@ -12,7 +12,7 @@ describe(packageJson.name, () => { app = await createApp( { apiSpec }, 3005, - (app) => { + app => { app.post(`${app.basePath}/one_of`, (req, res) => { res.json(req.body); }); @@ -80,9 +80,11 @@ describe(packageJson.name, () => { ], }) .expect(400) - .then((r) => { + .then(r => { const e = r.body; - expect(e.message).to.contain('must match exactly one schema in oneOf'); + expect(e.message).to.contain( + 'must match exactly one schema in oneOf', + ); }); }); @@ -134,9 +136,11 @@ describe(packageJson.name, () => { ], }) .expect(400) - .then((r) => { + .then(r => { const e = r.body; - expect(e.message).to.contain('must match exactly one schema in oneOf'); + expect(e.message).to.contain( + 'must match exactly one schema in oneOf', + ); }); }); }); diff --git a/test/oneof.readonly.yaml b/test/oneof.readonly.yaml index 6e1a49a0..e2501405 100644 --- a/test/oneof.readonly.yaml +++ b/test/oneof.readonly.yaml @@ -2,7 +2,7 @@ openapi: 3.0.0 info: title: Dummy API description: Dummy API - version: '0.1.0' + version: "0.1.0" servers: - url: /v1 paths: @@ -10,54 +10,54 @@ paths: post: requestBody: content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/subE' - - $ref: '#/components/schemas/subF' - discriminator: - propertyName: type - mapping: - A: '#/components/schemas/subE' - B: '#/components/schemas/subF' + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/subE' + - $ref: '#/components/schemas/subF' + discriminator: + propertyName: type + mapping: + A: '#/components/schemas/subE' + B: '#/components/schemas/subF' responses: - 200: - description: successful operation + 200: + description: successful operation /any_of: post: requestBody: content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/subA' - - $ref: '#/components/schemas/subB' - discriminator: - propertyName: type - mapping: - A: '#/components/schemas/subA' - B: '#/components/schemas/subB' + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/subA' + - $ref: '#/components/schemas/subB' + discriminator: + propertyName: type + mapping: + A: '#/components/schemas/subA' + B: '#/components/schemas/subB' responses: - 200: - description: successful operation + 200: + description: successful operation /one_of: post: requestBody: content: - application/json: - schema: - oneOf: - - $ref: '#/components/schemas/subC' - - $ref: '#/components/schemas/subD' - discriminator: - propertyName: type - mapping: - C: '#/components/schemas/subC' - D: '#/components/schemas/subD' + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/subC' + - $ref: '#/components/schemas/subD' + discriminator: + propertyName: type + mapping: + C: '#/components/schemas/subC' + D: '#/components/schemas/subD' responses: - 200: - description: successful operation + 200: + description: successful operation components: schemas: @@ -69,10 +69,10 @@ components: type: string type: type: string - enum: [A, B] + enum: [A, B] required: - id - - type + - type one_required: type: object @@ -82,7 +82,7 @@ components: type: string type: type: string - enum: [A, B] + enum: [A, B] required: - id @@ -103,10 +103,10 @@ components: type: string type: type: string - enum: [C, D] + enum: [C, D] required: - id - - type + - type subD: allOf: @@ -117,10 +117,10 @@ components: type: string type: type: string - enum: [C, D] + enum: [C, D] required: - id - - type + - type subE: allOf: @@ -128,4 +128,4 @@ components: subF: allOf: - - $ref: '#/components/schemas/one_required' + - $ref: '#/components/schemas/one_required' \ No newline at end of file diff --git a/test/openapi.spec.ts b/test/openapi.spec.ts index aa8190d1..9726eb15 100644 --- a/test/openapi.spec.ts +++ b/test/openapi.spec.ts @@ -38,11 +38,11 @@ describe(packageJson.name, () => { }); after(() => { - apps.forEach((app) => app.server.close()); + apps.forEach(app => app.server.close()); }); // [0,1] simulate range of 2 items - each item references an index in `apps` - [0, 1].forEach((i) => { + [0, 1].forEach(i => { describe(`GET ${basePath}/pets`, () => { it('should throw 400 on missing required query parameter', async () => request(apps[i]) @@ -50,7 +50,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e).to.have.length(2); expect(e[0].path).to.equal('/query/limit'); @@ -79,12 +79,12 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then((r) => { + .then(r => { expect(r.body.errors).to.deep.equal([ { path: '/query/unknown_param', - message: "Unknown query parameter 'unknown_param'", - }, + message: "Unknown query parameter 'unknown_param'" + } ]); })); @@ -98,7 +98,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('limit'); @@ -111,7 +111,7 @@ describe(packageJson.name, () => { .query(`limit=10&test=one&testJson={"foo": "bar"}`) .set('Accept', 'application/json') .expect('Content-Type', /json/) - .then((r) => { + .then(r => { expect(r.body) .to.have.property('message') .that.equals( @@ -142,7 +142,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('testJson'); @@ -155,12 +155,10 @@ describe(packageJson.name, () => { // query params default is style: form, explode: true - false, also comma separated list // testArrayNoExplode is set to form, explode false request(apps[i]) - .get( - `${basePath}/pets?limit=10&test=one&testArrayNoExplode2=categoryId%3AIN%3A%5B1%2C2%2C3%2C4%2C5%5D,itemId%3AEQ%3A2`, - ) + .get(`${basePath}/pets?limit=10&test=one&testArrayNoExplode2=categoryId%3AIN%3A%5B1%2C2%2C3%2C4%2C5%5D,itemId%3AEQ%3A2`) .set('Accept', 'application/json') .expect('Content-Type', /json/) - .expect(200)); + .expect(200)) it('should return 200 when comma separated array in query param', async () => // query params default is style: form, explode: true - false, also comma separated list @@ -184,7 +182,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then((r) => { + .then(r => { expect(r.body) .to.have.property('message') .that.equals( @@ -196,9 +194,7 @@ describe(packageJson.name, () => { request(apps[i]) .get(`${basePath}/pets`) .query( - `limit=10&test=one&testArrayNoExplode=${encodeURIComponent( - 'foo,bar,baz', - )}`, + `limit=10&test=one&testArrayNoExplode=${encodeURIComponent('foo,bar,baz')}`, ) .set('Accept', 'application/json') .expect('Content-Type', /json/) @@ -215,7 +211,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('testArrayNoExplode'); @@ -241,7 +237,7 @@ describe(packageJson.name, () => { .set('Accept', 'application/json') .expect('Content-Type', /json/) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e).to.have.length(1); expect(e[0].path).to.contain('testArrayExplode'); @@ -257,9 +253,11 @@ describe(packageJson.name, () => { .post(`${basePath}/pets`) .set('content-type', 'application/json') .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; - expect(e[0].message).to.equal("must have required property 'name'"); + expect(e[0].message).to.equal( + "must have required property 'name'", + ); })); it('should return 400 if required "name" property is missing', async () => @@ -267,9 +265,11 @@ describe(packageJson.name, () => { .post(`${basePath}/pets`) .send({}) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; - expect(e[0].message).to.equal("must have required property 'name'"); + expect(e[0].message).to.equal( + "must have required property 'name'", + ); })); it('should return 200 when post props are met', async () => @@ -279,7 +279,7 @@ describe(packageJson.name, () => { name: 'test', }) .expect(200) - .then((r) => { + .then(r => { expect(r.body.id).to.equal('new-id'); })); }); @@ -289,7 +289,7 @@ describe(packageJson.name, () => { request(apps[i]) .get('/not_under_an_openapi_basepath') .expect(200) - .then((r) => { + .then(r => { expect(r.body.id).to.equal('/not_under_an_openapi_basepath'); })); @@ -300,7 +300,7 @@ describe(packageJson.name, () => { request(apps[i]) .get(`${basePath}/route_not_defined_within_express`) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].message).to.equal( "must have required property 'name'", @@ -313,7 +313,7 @@ describe(packageJson.name, () => { .get(`${basePath}/route_not_defined_within_express`) .query({ name: 'test' }) .expect(404) - .then((r) => { + .then(r => { const e = r.body; // There is no route defined by express, hence the validator verifies parameters, // then it fails over to the express error handler. In this case returns empty @@ -325,7 +325,7 @@ describe(packageJson.name, () => { .get(`${basePath}/router_1/10`) .set('Accept', 'application/json') .expect(404) - .then((r) => { + .then(r => { const e = r.body.errors[0]; expect(e.message).to.equal('not found'); expect(e.path).to.equal(`${basePath}/router_1/10`); @@ -336,7 +336,7 @@ describe(packageJson.name, () => { .post(`${basePath}/route_not_defined_within_express`) .send() .expect(405) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].message).to.equal('POST method not allowed'); expect(e[0].path).to.equal( @@ -351,7 +351,7 @@ describe(packageJson.name, () => { name: 'test', }) .expect(404) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].message).to.equal('not found'); expect(e[0].path).to.equal(`${basePath}/unknown_route`); @@ -364,7 +364,7 @@ describe(packageJson.name, () => { name: 'test', }) .expect(404) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].message).to.equal('not found'); expect(e[0].path).to.equal( @@ -378,7 +378,7 @@ describe(packageJson.name, () => { .send('stuff') .set('content-type', 'application/xml') .expect(415) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].message).to.equal( 'unsupported media type application/xml', @@ -390,7 +390,7 @@ describe(packageJson.name, () => { .patch(`${basePath}/pets`) .send({ name: 'test' }) .expect(405) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].message).to.equal('PATCH method not allowed'); })); @@ -403,7 +403,7 @@ describe(packageJson.name, () => { return request(apps[i]) .get(`${basePath}/pets/${id}`) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].path).contains('id'); expect(e[0].message).equals('must be integer'); @@ -419,7 +419,7 @@ describe(packageJson.name, () => { testArrayNoExplode: ['unknown_value'], }) .expect(400) - .then((r) => { + .then(r => { const e = r.body.errors; expect(e[0].message).equals( 'must be equal to one of the allowed values: foo, bar, baz', @@ -433,7 +433,7 @@ describe(packageJson.name, () => { return request(apps[i]) .get(`${basePath}/pets/${id}/attributes/${attributeId}`) .expect(200) - .then((r) => { + .then(r => { expect(r.body.id).equals(Number.parseInt(id)); expect(r.body.attribute_id).equals(Number.parseInt(attributeId)); }); @@ -444,7 +444,7 @@ describe(packageJson.name, () => { return request(apps[i]) .get(`${basePath}/pets/${id}`) .expect(200) - .then((r) => { + .then(r => { expect(r.body.id).equals(id); }); }); diff --git a/test/openapi_3.1/components.spec.ts b/test/openapi_3.1/components.spec.ts index d4ddd28d..958c81bb 100644 --- a/test/openapi_3.1/components.spec.ts +++ b/test/openapi_3.1/components.spec.ts @@ -1,6 +1,6 @@ import * as request from 'supertest'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('components support - OpenAPI 3.1', () => { let app; @@ -22,6 +22,9 @@ describe('components support - OpenAPI 3.1', () => { it('should support an API that only has components defined, but provides no routes', () => { // The component is not made available by the provider API, so the request will return 404 // This test ensures that the request flow happens normally without any interruptions due to being a component - return request(app).get(`${app.basePath}/components`).expect(404); + return request(app) + .get(`${app.basePath}/components`) + .expect(404); }); -}); + +}) \ No newline at end of file diff --git a/test/openapi_3.1/components_path_items.spec.ts b/test/openapi_3.1/components_path_items.spec.ts index bf0957e6..cbd282da 100644 --- a/test/openapi_3.1/components_path_items.spec.ts +++ b/test/openapi_3.1/components_path_items.spec.ts @@ -1,27 +1,23 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('component path item support - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join( - 'test', - 'openapi_3.1', - 'resources', - 'components_path_items.yaml', - ); + const apiSpec = join('test', 'openapi_3.1', 'resources', 'components_path_items.yaml'); app = await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, - (app) => - app.use( - express - .Router() - .get(`/v1/entity`, (req, res) => res.status(200).json({})), - ), + (app) => app.use( + express + .Router() + .get(`/v1/entity`, (req, res) => + res.status(200).json({}), + ), + ) ); }); @@ -30,6 +26,9 @@ describe('component path item support - OpenAPI 3.1', () => { }); it('should support path item on components', async () => { - return request(app).get(`${app.basePath}/entity`).expect(200); + return request(app) + .get(`${app.basePath}/entity`) + .expect(200); }); -}); + +}) \ No newline at end of file diff --git a/test/openapi_3.1/info_summary.spec.ts b/test/openapi_3.1/info_summary.spec.ts index b1144ea1..20e8c5dc 100644 --- a/test/openapi_3.1/info_summary.spec.ts +++ b/test/openapi_3.1/info_summary.spec.ts @@ -1,17 +1,12 @@ import * as request from 'supertest'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('summary support - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join( - 'test', - 'openapi_3.1', - 'resources', - 'info_summary.yaml', - ); + const apiSpec = join('test', 'openapi_3.1', 'resources', 'info_summary.yaml'); app = await createApp( { apiSpec, validateRequests: true }, 3005, @@ -27,6 +22,9 @@ describe('summary support - OpenAPI 3.1', () => { it('should support an API that has an info with a summary defined', () => { // The endpoint is not made available by the provider API, so the request will return 404 // This test ensures that the request flow happens normally without any interruptions - return request(app).get(`${app.basePath}/webhook`).expect(404); + return request(app) + .get(`${app.basePath}/webhook`) + .expect(404); }); -}); + +}) \ No newline at end of file diff --git a/test/openapi_3.1/license_identifier.spec.ts b/test/openapi_3.1/license_identifier.spec.ts index 10f307c1..7f615a93 100644 --- a/test/openapi_3.1/license_identifier.spec.ts +++ b/test/openapi_3.1/license_identifier.spec.ts @@ -1,17 +1,12 @@ import * as request from 'supertest'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('identifier support - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join( - 'test', - 'openapi_3.1', - 'resources', - 'license_identifier.yaml', - ); + const apiSpec = join('test', 'openapi_3.1', 'resources', 'license_identifier.yaml'); app = await createApp( { apiSpec, validateRequests: true }, 3005, @@ -27,6 +22,9 @@ describe('identifier support - OpenAPI 3.1', () => { it('should support an API that has an info with a summary defined', () => { // The endpoint is not made available by the provider API, so the request will return 404 // This test ensures that the request flow happens normally without any interruptions - return request(app).get(`${app.basePath}/webhook`).expect(404); + return request(app) + .get(`${app.basePath}/webhook`) + .expect(404); }); -}); + +}) \ No newline at end of file diff --git a/test/openapi_3.1/non_defined_semantics_request_body.spec.ts b/test/openapi_3.1/non_defined_semantics_request_body.spec.ts index 032b3ba7..e843a587 100644 --- a/test/openapi_3.1/non_defined_semantics_request_body.spec.ts +++ b/test/openapi_3.1/non_defined_semantics_request_body.spec.ts @@ -1,29 +1,25 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('Request body in operations without well defined semantics - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join( - 'test', - 'openapi_3.1', - 'resources', - 'non_defined_semantics_request_body.yaml', - ); + const apiSpec = join('test', 'openapi_3.1', 'resources', 'non_defined_semantics_request_body.yaml'); app = await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, - (app) => - app.use( - express.Router().get(`/v1/entity`, (req, res) => + (app) => app.use( + express + .Router() + .get(`/v1/entity`, (req, res) => res.status(200).json({ - property: null, + property: null }), ), - ), + ) ); }); @@ -37,7 +33,7 @@ describe('Request body in operations without well defined semantics - OpenAPI 3. return request(app) .get(`${app.basePath}/entity`) .set('Content-Type', 'application/json') - .send({ request: 123 }) + .send({request: 123}) .expect(400); }); @@ -46,7 +42,7 @@ describe('Request body in operations without well defined semantics - OpenAPI 3. return request(app) .delete(`${app.basePath}/entity`) .set('Content-Type', 'application/json') - .send({ request: 123 }) + .send({request: 123}) .expect(400); }); -}); +}) \ No newline at end of file diff --git a/test/openapi_3.1/path_no_response.spec.ts b/test/openapi_3.1/path_no_response.spec.ts index 6c7611dd..b40619e3 100644 --- a/test/openapi_3.1/path_no_response.spec.ts +++ b/test/openapi_3.1/path_no_response.spec.ts @@ -1,27 +1,25 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('operation object without response - OpenAPI 3.1', () => { let app; before(async () => { - const apiSpec = join( - 'test', - 'openapi_3.1', - 'resources', - 'path_no_response.yaml', - ); + const apiSpec = join('test', 'openapi_3.1', 'resources', 'path_no_response.yaml'); app = await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, - (app) => - app.use( - express.Router().get(`/v1`, (req, res) => res.status(200).end()), - ), + (app) => app.use( + express + .Router() + .get(`/v1`, (req, res) => + res.status(200).end(), + ), + ) ); - app; + app }); after(() => { @@ -30,6 +28,9 @@ describe('operation object without response - OpenAPI 3.1', () => { // In OpenAPI 3.1 it's possible to have a path without a response defined it('should support endpoint with defined operation object without response', () => { - return request(app).get(`${app.basePath}`).expect(200); + return request(app) + .get(`${app.basePath}`) + .expect(200); }); -}); + +}) \ No newline at end of file diff --git a/test/openapi_3.1/resources/components.yaml b/test/openapi_3.1/resources/components.yaml index d70fd47c..b968adec 100644 --- a/test/openapi_3.1/resources/components.yaml +++ b/test/openapi_3.1/resources/components.yaml @@ -3,4 +3,4 @@ openapi: 3.1.0 info: title: API version: 1.0.0 -components: {} +components: {} \ No newline at end of file diff --git a/test/openapi_3.1/resources/components_path_items.yaml b/test/openapi_3.1/resources/components_path_items.yaml index df7579e4..030e6757 100644 --- a/test/openapi_3.1/resources/components_path_items.yaml +++ b/test/openapi_3.1/resources/components_path_items.yaml @@ -1,21 +1,21 @@ openapi: 3.1.0 info: title: Example specification - version: '1.0' + version: "1.0" servers: - url: /v1 components: - pathItems: + pathItems: entity: - get: + get: description: 'test' - responses: + responses: 200: description: GETS my entity content: application/json: schema: - type: object + type: object paths: /entity: $ref: '#/components/pathItems/entity' diff --git a/test/openapi_3.1/resources/info_summary.yaml b/test/openapi_3.1/resources/info_summary.yaml index 079bd435..27e120cd 100644 --- a/test/openapi_3.1/resources/info_summary.yaml +++ b/test/openapi_3.1/resources/info_summary.yaml @@ -4,4 +4,4 @@ info: title: API summary: My lovely API version: 1.0.0 -components: {} +components: {} \ No newline at end of file diff --git a/test/openapi_3.1/resources/license_identifier.yaml b/test/openapi_3.1/resources/license_identifier.yaml index 9530f345..85dd47a1 100644 --- a/test/openapi_3.1/resources/license_identifier.yaml +++ b/test/openapi_3.1/resources/license_identifier.yaml @@ -7,4 +7,4 @@ info: license: name: Apache identifier: Apache-2.0 -components: {} +components: {} \ No newline at end of file diff --git a/test/openapi_3.1/resources/non_defined_semantics_request_body.yaml b/test/openapi_3.1/resources/non_defined_semantics_request_body.yaml index ef411185..5114a27a 100644 --- a/test/openapi_3.1/resources/non_defined_semantics_request_body.yaml +++ b/test/openapi_3.1/resources/non_defined_semantics_request_body.yaml @@ -26,7 +26,7 @@ paths: '200': description: OK content: - application/json: + application/json: schema: title: Entity type: object @@ -46,10 +46,10 @@ paths: '200': description: OK content: - application/json: + application/json: schema: title: Entity type: object properties: property: - type: ['string', 'null'] + type: ['string', 'null'] \ No newline at end of file diff --git a/test/openapi_3.1/resources/path_no_response.yaml b/test/openapi_3.1/resources/path_no_response.yaml index 8b36f052..5426037b 100644 --- a/test/openapi_3.1/resources/path_no_response.yaml +++ b/test/openapi_3.1/resources/path_no_response.yaml @@ -8,4 +8,4 @@ servers: - url: /v1 paths: /: - get: {} + get: {} \ No newline at end of file diff --git a/test/openapi_3.1/resources/server_variable_no_default.yaml b/test/openapi_3.1/resources/server_variable_no_default.yaml index c39cab8a..8408bf44 100644 --- a/test/openapi_3.1/resources/server_variable_no_default.yaml +++ b/test/openapi_3.1/resources/server_variable_no_default.yaml @@ -9,4 +9,5 @@ servers: variables: var: enum: ['a', 'b'] -components: {} +components: + {} \ No newline at end of file diff --git a/test/openapi_3.1/resources/type_null.yaml b/test/openapi_3.1/resources/type_null.yaml index 20a8020b..54d885f6 100644 --- a/test/openapi_3.1/resources/type_null.yaml +++ b/test/openapi_3.1/resources/type_null.yaml @@ -7,16 +7,17 @@ servers: paths: /entity: get: - summary: test - description: GETS my entity - responses: - '200': - description: OK - content: - application/json: - schema: - title: Entity - type: object - properties: - property: - type: ['string', 'null'] + summary: test + description: GETS my entity + responses: + '200': + description: OK + content: + application/json: + schema: + title: Entity + type: object + properties: + property: + type: ['string', 'null'] + \ No newline at end of file diff --git a/test/openapi_3.1/resources/unevaluated_properties.yaml b/test/openapi_3.1/resources/unevaluated_properties.yaml index b5445333..cc40845a 100644 --- a/test/openapi_3.1/resources/unevaluated_properties.yaml +++ b/test/openapi_3.1/resources/unevaluated_properties.yaml @@ -25,4 +25,4 @@ paths: $ref: '#/components/schemas/EntityRequest' responses: '204': - description: No Content + description: No Content \ No newline at end of file diff --git a/test/openapi_3.1/resources/webhook.yaml b/test/openapi_3.1/resources/webhook.yaml index 941aaa57..27bbd8e2 100644 --- a/test/openapi_3.1/resources/webhook.yaml +++ b/test/openapi_3.1/resources/webhook.yaml @@ -14,9 +14,9 @@ webhooks: content: application/json: schema: - $ref: '#/components/schemas/Pet' + $ref: "#/components/schemas/Pet" responses: - '200': + "200": description: Return a 200 status to indicate that the data was received successfully components: @@ -32,4 +32,4 @@ components: name: type: string tag: - type: string + type: string \ No newline at end of file diff --git a/test/openapi_3.1/server_variable.spec.ts b/test/openapi_3.1/server_variable.spec.ts index c028898a..d790b9c6 100644 --- a/test/openapi_3.1/server_variable.spec.ts +++ b/test/openapi_3.1/server_variable.spec.ts @@ -1,24 +1,21 @@ import * as request from 'supertest'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('server variable - OpenAPI 3.1', () => { it('returns 500 when server variable has no default property', async () => { - const apiSpec = join( - 'test', - 'openapi_3.1', - 'resources', - 'server_variable_no_default.yaml', - ); - const app = (await createApp( + const apiSpec = join('test', 'openapi_3.1', 'resources', 'server_variable_no_default.yaml'); + const app = await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, undefined, false, - )) as any; + ) as any; - await request(app).get(`${app.basePath}`).expect(500); + await request(app) + .get(`${app.basePath}`) + .expect(500); app.server.close(); }); -}); +}) \ No newline at end of file diff --git a/test/openapi_3.1/type_null.spec.ts b/test/openapi_3.1/type_null.spec.ts index b9b69bc3..452626c2 100644 --- a/test/openapi_3.1/type_null.spec.ts +++ b/test/openapi_3.1/type_null.spec.ts @@ -1,7 +1,7 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('type null support - OpenAPI 3.1', () => { let app; @@ -11,14 +11,15 @@ describe('type null support - OpenAPI 3.1', () => { app = await createApp( { apiSpec, validateRequests: true, validateResponses: true }, 3005, - (app) => - app.use( - express.Router().get(`/v1/entity`, (req, res) => + (app) => app.use( + express + .Router() + .get(`/v1/entity`, (req, res) => res.status(200).json({ - property: null, + property: null }), ), - ), + ) ); }); @@ -28,6 +29,9 @@ describe('type null support - OpenAPI 3.1', () => { // In OpenAPI 3.1, nullable = true was replaced by types = [..., null]. This test ensure that it works with Express OpenAPI Validator it('should support an API with types set to null', async () => { - return request(app).get(`${app.basePath}/entity`).expect(200); + return request(app) + .get(`${app.basePath}/entity`) + .expect(200); }); -}); + +}) \ No newline at end of file diff --git a/test/openapi_3.1/unevaluated_properties.spec.ts b/test/openapi_3.1/unevaluated_properties.spec.ts index df6f0793..edb84535 100644 --- a/test/openapi_3.1/unevaluated_properties.spec.ts +++ b/test/openapi_3.1/unevaluated_properties.spec.ts @@ -1,24 +1,23 @@ import * as request from 'supertest'; import * as express from 'express'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('Unevaluated Properties in requests', () => { let app; before(async () => { - const apiSpec = join( - 'test', - 'openapi_3.1', - 'resources', - 'unevaluated_properties.yaml', - ); - app = await createApp({ apiSpec, validateRequests: true }, 3005, (app) => - app.use( + const apiSpec = join('test', 'openapi_3.1', 'resources', 'unevaluated_properties.yaml'); + app = await createApp( + { apiSpec, validateRequests: true }, + 3005, + (app) => app.use( express .Router() - .post(`/v1/entity`, (_req, res) => res.status(204).json()), - ), + .post(`/v1/entity`, (_req, res) => + res.status(204).json(), + ), + ) ); }); @@ -26,11 +25,12 @@ describe('Unevaluated Properties in requests', () => { app.server.close(); }); + it('should reject request body with unevaluated properties', async () => { return request(app) .post(`${app.basePath}/entity`) .set('Content-Type', 'application/json') - .send({ request: '123', additionalProperty: '321' }) + .send({request: '123', additionalProperty: '321'}) .expect(400); }); @@ -38,7 +38,8 @@ describe('Unevaluated Properties in requests', () => { return request(app) .post(`${app.basePath}/entity`) .set('Content-Type', 'application/json') - .send({ request: '123' }) + .send({request: '123' }) .expect(204); }); -}); + +}) \ No newline at end of file diff --git a/test/openapi_3.1/webhook.spec.ts b/test/openapi_3.1/webhook.spec.ts index 3e840502..58e81b1d 100644 --- a/test/openapi_3.1/webhook.spec.ts +++ b/test/openapi_3.1/webhook.spec.ts @@ -1,6 +1,6 @@ import * as request from 'supertest'; -import { createApp } from '../common/app'; -import { join } from 'path'; +import { createApp } from "../common/app"; +import { join } from "path"; describe('webhook support - OpenAPI 3.1', () => { let app; @@ -22,6 +22,9 @@ describe('webhook support - OpenAPI 3.1', () => { it('should support an API that only has webhooks defined, but provides no routes', () => { // The webhook is not made available by the provider API, so the request will return 404 // This test ensures that the request flow happens normally without any interruptions due to being a webhook - return request(app).get(`${app.basePath}/webhook`).expect(404); + return request(app) + .get(`${app.basePath}/webhook`) + .expect(404); }); -}); + +}) \ No newline at end of file diff --git a/test/optional-request-body.spec.ts b/test/optional-request-body.spec.ts index ad49fa5b..f99aa8d6 100644 --- a/test/optional-request-body.spec.ts +++ b/test/optional-request-body.spec.ts @@ -33,7 +33,9 @@ describe(packageJson.name, () => { .expect(201)); it('create document should return 201 with empty body', async () => - request(app).post(`/documents`).expect(201)); + request(app) + .post(`/documents`) + .expect(201)); it('return 415', async () => request(app) diff --git a/test/path.level.parameters.spec.ts b/test/path.level.parameters.spec.ts index ac3447a2..7f61a476 100644 --- a/test/path.level.parameters.spec.ts +++ b/test/path.level.parameters.spec.ts @@ -42,7 +42,7 @@ describe(packageJson.name, () => { .get(`${app.basePath}/path_level_parameters?operationLevel=123`) .send() .expect(400) - .then((r) => { + .then(r => { expect(r.body.errors).to.be.an('array'); expect(r.body.errors).to.have.length(1); const message = r.body.errors[0].message; @@ -54,7 +54,7 @@ describe(packageJson.name, () => { .get(`${app.basePath}/path_level_parameters?pathLevel=123`) .send() .expect(400) - .then((r) => { + .then(r => { expect(r.body.errors).to.be.an('array'); expect(r.body.errors).to.have.length(1); const message = r.body.errors[0].message; @@ -68,10 +68,10 @@ describe(packageJson.name, () => { .get(`${app.basePath}/path_level_parameters`) .send() .expect(400) - .then((r) => { + .then(r => { expect(r.body.errors).to.be.an('array'); expect(r.body.errors).to.have.length(2); - const messages = r.body.errors.map((err) => err.message); + const messages = r.body.errors.map(err => err.message); expect(messages).to.have.members([ "must have required property 'pathLevel'", "must have required property 'operationLevel'", @@ -80,9 +80,7 @@ describe(packageJson.name, () => { it('should return 200 if both pathLevel and operationLevel query parameter are provided', async () => request(app) - .get( - `${app.basePath}/path_level_parameters?operationLevel=123&pathLevel=123`, - ) + .get(`${app.basePath}/path_level_parameters?operationLevel=123&pathLevel=123`) .send() .expect(200)); }); diff --git a/test/paths.sort.spec.ts b/test/paths.sort.spec.ts index 1adfaad7..6d2fc4fa 100644 --- a/test/paths.sort.spec.ts +++ b/test/paths.sort.spec.ts @@ -1,4 +1,6 @@ -import { sortRoutes } from '../src/framework/openapi.spec.loader'; +import { + sortRoutes, +} from '../src/framework/openapi.spec.loader'; import { expect } from 'chai'; describe('url sorter', () => { @@ -36,7 +38,7 @@ describe('url sorter', () => { }); function asRouteMetadatas(urls: string[]) { - return urls.map((u) => ({ + return urls.map(u => ({ expressRoute: u, })); } diff --git a/test/query.params.allow.unknown.spec.ts b/test/query.params.allow.unknown.spec.ts index cd43cd4c..22b360fa 100644 --- a/test/query.params.allow.unknown.spec.ts +++ b/test/query.params.allow.unknown.spec.ts @@ -15,7 +15,7 @@ describe(packageJson.name, () => { app = await createApp( { apiSpec, validateRequests: { allowUnknownQueryParameters: true } }, 3005, - (app) => + app => app.use( `${app.basePath}`, express @@ -62,7 +62,7 @@ describe(packageJson.name, () => { unknown_prop: 'test', }) .expect(400) - .then((r) => { + .then(r => { expect(r.body.errors).to.be.an('array'); })); }); diff --git a/test/query.params.spec.ts b/test/query.params.spec.ts index 9a546f27..536f0034 100644 --- a/test/query.params.spec.ts +++ b/test/query.params.spec.ts @@ -11,7 +11,7 @@ describe(packageJson.name, () => { before(async () => { // Set up the express app const apiSpec = path.join('test', 'resources', 'query.params.yaml'); - app = await createApp({ apiSpec }, 3005, (app) => + app = await createApp({ apiSpec }, 3005, app => app.use( `${app.basePath}`, express @@ -50,7 +50,7 @@ describe(packageJson.name, () => { name: 'max', }) .expect(400) - .then((r) => { + .then(r => { expect(r.body.errors).to.be.an('array'); })); @@ -58,7 +58,7 @@ describe(packageJson.name, () => { request(app) .get(`${app.basePath}/no_query_params`) .expect(200) - .then((r) => { + .then(r => { expect(r.body.complete).to.equal(true); })); @@ -74,7 +74,7 @@ describe(packageJson.name, () => { unknown_prop: 'test', }) .expect(400) - .then((r) => { + .then(r => { expect(r.body.errors).to.be.an('array'); })); @@ -98,11 +98,13 @@ describe(packageJson.name, () => { owner_name: 'carmine', }) .expect(400) - .then((r) => { + .then(r => { expect(r.body) .to.have.property('message') .that.equals("Empty value found for query parameter 'breed'"); - expect(r.body.errors).to.be.an('array').with.length(1); + expect(r.body.errors) + .to.be.an('array') + .with.length(1); expect(r.body.errors[0].path).to.equal('/query/breed'); })); @@ -129,7 +131,7 @@ describe(packageJson.name, () => { request(app) .get(`${app.basePath}/no_reserved?value=ThisHas$ReservedChars!`) .expect(400) - .then((r) => { + .then(r => { const body = r.body; expect(body.message).equals( "Parameter 'value' must be url encoded. Its value may not contain reserved characters.", diff --git a/test/query.serialization.ts b/test/query.serialization.ts index 4070714d..019e55ab 100644 --- a/test/query.serialization.ts +++ b/test/query.serialization.ts @@ -13,12 +13,8 @@ describe('styles', () => { `/`, express .Router() - .get('/api/q_form_explode', (req, res) => - res.json({ query: req.query }), - ) - .get('/api/q_form_nexplode', (req, res) => - res.json({ query: req.query }), - ), + .get('/api/q_form_explode', (req, res) => res.json({ query: req.query })) + .get('/api/q_form_nexplode', (req, res) => res.json({ query: req.query })), ), ); }); diff --git a/test/read.only.removeadditional.spec.ts b/test/read.only.removeadditional.spec.ts index cad46ce9..2f065c04 100644 --- a/test/read.only.removeadditional.spec.ts +++ b/test/read.only.removeadditional.spec.ts @@ -10,58 +10,51 @@ describe(packageJson.name, () => { before(async () => { // Set up the express app const apiSpec = path.join('test', 'resources', 'read.only.yaml'); - app = await createApp( - { - apiSpec, - validateRequests: { removeAdditional: true }, - validateResponses: true, - }, - 3005, - (app) => - app - .post(`${app.basePath}/products`, (req, res) => res.json(req.body)) - .get(`${app.basePath}/products`, (req, res) => - res.json([ - { - id: 'id_1', - name: 'name_1', - price: 9.99, - created_at: new Date().toISOString(), - }, - ]), - ) - .post(`${app.basePath}/products/inlined`, (req, res) => - res.json(req.body), - ) - .post(`${app.basePath}/user`, (req, res) => - res.json({ - ...req.body, - ...(req.query.include_id ? { id: 'test_id' } : {}), - }), - ) - .post(`${app.basePath}/user_inlined`, (req, res) => - res.json({ - ...req.body, - ...(req.query.include_id ? { id: 'test_id' } : {}), - }), - ) - .post(`${app.basePath}/products/nested`, (req, res) => { - const body = req.body; - body.id = 'test'; - body.created_at = new Date().toISOString(); - body.reviews = body.reviews.map((r) => ({ - id: 99, - rating: r.rating ?? 2, - })); - res.json(body); - }) - .post(`${app.basePath}/readonly_required_allof`, (req, res) => { - const json = { - name: 'My Name', - ...(req.query.include_id ? { id: 'test_id' } : {}), - }; - res.json(json); + app = await createApp({ apiSpec, validateRequests: {removeAdditional:true}, validateResponses: true }, 3005, (app) => + app + .post(`${app.basePath}/products`, (req, res) => res.json(req.body)) + .get(`${app.basePath}/products`, (req, res) => + res.json([ + { + id: 'id_1', + name: 'name_1', + price: 9.99, + created_at: new Date().toISOString(), + }, + ]), + ) + .post(`${app.basePath}/products/inlined`, (req, res) => + res.json(req.body), + ) + .post(`${app.basePath}/user`, (req, res) => + res.json({ + ...req.body, + ...(req.query.include_id ? { id: 'test_id' } : {}), }), + ) + .post(`${app.basePath}/user_inlined`, (req, res) => + res.json({ + ...req.body, + ...(req.query.include_id ? { id: 'test_id' } : {}), + }), + ) + .post(`${app.basePath}/products/nested`, (req, res) => { + const body = req.body; + body.id = 'test'; + body.created_at = new Date().toISOString(); + body.reviews = body.reviews.map((r) => ({ + id: 99, + rating: r.rating ?? 2, + })); + res.json(body); + }) + .post(`${app.basePath}/readonly_required_allof`, (req, res) => { + const json = { + name: 'My Name', + ...(req.query.include_id ? { id: 'test_id' } : {}), + }; + res.json(json); + }), ); }); @@ -70,22 +63,23 @@ describe(packageJson.name, () => { }); it('should remove read only properties in requests thanks to removeAdditional', async () => - request(app) - .post(`${app.basePath}/products`) - .set('content-type', 'application/json') - .send({ - id: 'id_1', - name: 'some name', - price: 10.99, - created_at: new Date().toISOString(), - }) - .expect(200) - .then((r) => { - const body = r.body; - // id is a readonly property and should not be allowed in the request - // but, as removeAdditional is true for requests, it should be deleted before entering in the route - expect(body.id).to.be.undefined; - })); + request(app) + .post(`${app.basePath}/products`) + .set('content-type', 'application/json') + .send({ + id: 'id_1', + name: 'some name', + price: 10.99, + created_at: new Date().toISOString(), + }) + .expect(200) + .then((r) => { + const body = r.body; + // id is a readonly property and should not be allowed in the request + // but, as removeAdditional is true for requests, it should be deleted before entering in the route + expect(body.id).to.be.undefined; + })); + it('should allow read only properties in responses', async () => request(app) @@ -108,11 +102,12 @@ describe(packageJson.name, () => { .expect(200) .then((r) => { const body = r.body; - // id is a readonly property and should not not be allowed in the request - // but, as removeAdditional is true for requests, it should be deleted before entering in the route - expect(body.id).to.be.undefined; + // id is a readonly property and should not not be allowed in the request + // but, as removeAdditional is true for requests, it should be deleted before entering in the route + expect(body.id).to.be.undefined; })); + it('should remove read only properties in requests (nested and deep nested schema $refs) thanks to removeAdditional', async () => request(app) .post(`${app.basePath}/products/nested`) @@ -122,20 +117,18 @@ describe(packageJson.name, () => { name: 'some name', price: 10.99, created_at: new Date().toISOString(), - reviews: [ - { - id: 10, - rating: 5, - }, - ], + reviews: [{ + id: 10, + rating: 5, + }], }) .expect(200) .then((r) => { const body = r.body; - // id is a readonly property and should not not be allowed in the request - // but, as removeAdditional is true for requests, it should be deleted before entering in the route - expect(body.id).to.be.equal('test'); - expect(body.reviews[0].id).to.be.equal(99); + // id is a readonly property and should not not be allowed in the request + // but, as removeAdditional is true for requests, it should be deleted before entering in the route + expect(body.id).to.be.equal('test'); + expect(body.reviews[0].id).to.be.equal(99); })); it('should pass validation if required read only properties to be missing from request ($ref)', async () => diff --git a/test/read.only.spec.ts b/test/read.only.spec.ts index 66d62535..da4ffc0e 100644 --- a/test/read.only.spec.ts +++ b/test/read.only.spec.ts @@ -113,12 +113,10 @@ describe(packageJson.name, () => { name: 'some name', price: 10.99, created_at: new Date().toISOString(), - reviews: [ - { - id: 'review_id', - rating: 5, - }, - ], + reviews: [{ + id: 'review_id', + rating: 5, + }], }) .expect(400) .then((r) => { diff --git a/test/request.bodies.ref.spec.ts b/test/request.bodies.ref.spec.ts index d738c756..0a263c55 100644 --- a/test/request.bodies.ref.spec.ts +++ b/test/request.bodies.ref.spec.ts @@ -125,7 +125,9 @@ describe('request bodies', () => { expect(r.body.errors).to.be.an('array'); expect(r.body.errors).to.have.length(1); const message = r.body.errors[0].message; - expect(message).to.equal("must have required property 'testProperty'"); + expect(message).to.equal( + "must have required property 'testProperty'", + ); })); it('should return 200 if testProperty body property is provided', async () => diff --git a/test/resources/699.yaml b/test/resources/699.yaml index 2107f2f8..0126109f 100644 --- a/test/resources/699.yaml +++ b/test/resources/699.yaml @@ -1,7 +1,7 @@ -openapi: '3.0.0' +openapi: "3.0.0" info: - title: 'Test for allOf' - version: '1' + title: "Test for allOf" + version: "1" servers: - url: /v1/ paths: @@ -12,7 +12,7 @@ paths: in: path required: true schema: - $ref: '#/components/schemas/ObjectId' + $ref: "#/components/schemas/ObjectId" - name: baddateresponse in: query schema: @@ -26,28 +26,28 @@ paths: in: query required: false schema: - $ref: '#/components/schemas/ShortOrLong' + $ref: "#/components/schemas/ShortOrLong" responses: 200: - description: '' + description: "" content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" /users: post: requestBody: - content: + content : application/json: schema: $ref: '#/components/schemas/User' responses: 200: - description: '' + description: "" content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" components: schemas: ObjectId: @@ -70,7 +70,7 @@ components: type: object properties: modificationDate: - $ref: '#/components/schemas/Date' + $ref: "#/components/schemas/Date" StringList: type: string format: string-list @@ -78,19 +78,19 @@ components: type: object properties: id: - $ref: '#/components/schemas/ObjectId' + $ref: "#/components/schemas/ObjectId" tags: - $ref: '#/components/schemas/StringList' + $ref: "#/components/schemas/StringList" creationDateTime: - $ref: '#/components/schemas/DateTime' + $ref: "#/components/schemas/DateTime" creationDate: - $ref: '#/components/schemas/Date' + $ref: "#/components/schemas/Date" shortOrLong: - $ref: '#/components/schemas/ShortOrLong' + $ref: "#/components/schemas/ShortOrLong" history: type: array items: - $ref: '#/components/schemas/HistoryItem' + $ref: "#/components/schemas/HistoryItem" historyWithoutRef: type: array items: @@ -99,3 +99,4 @@ components: modificationDate: type: string format: date + diff --git a/test/resources/821.yaml b/test/resources/821.yaml index edc85cf9..e9533d76 100644 --- a/test/resources/821.yaml +++ b/test/resources/821.yaml @@ -4,7 +4,7 @@ info: title: Test additionalProperties date-time paths: /test: - get: + get: responses: '200': description: foo diff --git a/test/resources/additional.props.query.params.yaml b/test/resources/additional.props.query.params.yaml index e9214e67..b75d7cd7 100644 --- a/test/resources/additional.props.query.params.yaml +++ b/test/resources/additional.props.query.params.yaml @@ -37,3 +37,5 @@ paths: responses: '200': description: the response + + diff --git a/test/resources/all.of.yaml b/test/resources/all.of.yaml index 8a8c812c..7110589d 100644 --- a/test/resources/all.of.yaml +++ b/test/resources/all.of.yaml @@ -1,4 +1,4 @@ -openapi: '3.0.0' +openapi: "3.0.0" info: version: 1.0.0 title: Test @@ -13,10 +13,10 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Pet' + $ref: "#/components/schemas/Pet" responses: - '200': + "200": description: success components: @@ -37,7 +37,7 @@ components: # This causes AVJ validation to fail - https://github.com/epoberezkin/ajv/issues/837 # additionalProperties: false allOf: - - $ref: '#/components/schemas/NewPet' + - $ref: "#/components/schemas/NewPet" - required: - id type: object diff --git a/test/resources/circular.yaml b/test/resources/circular.yaml index e6d580ca..f0a2397f 100644 --- a/test/resources/circular.yaml +++ b/test/resources/circular.yaml @@ -14,7 +14,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: '#/components/schemas/User' responses: '200': description: Updated @@ -30,9 +30,11 @@ components: type: number name: type: string - favorite: + favorite: $ref: '#/components/schemas/User' children: type: array items: $ref: '#/components/schemas/User' + + \ No newline at end of file diff --git a/test/resources/coercion.yaml b/test/resources/coercion.yaml index 9de59596..5e9344f4 100644 --- a/test/resources/coercion.yaml +++ b/test/resources/coercion.yaml @@ -51,16 +51,16 @@ paths: description: Returns pets by name operationId: addPet parameters: - - in: query - name: filter - schema: - type: object - additionalProperties: false - properties: - names: - type: array - items: - type: string + - in: query + name: filter + schema: + type: object + additionalProperties: false + properties: + names: + type: array + items: + type: string responses: '200': description: pet response diff --git a/test/resources/controller-with-default.ts b/test/resources/controller-with-default.ts index 442ca7c6..b52090a2 100644 --- a/test/resources/controller-with-default.ts +++ b/test/resources/controller-with-default.ts @@ -1,3 +1,3 @@ export default function (req, res) { - res.json({ success: true }).end(); + res.json({success: true}).end(); } diff --git a/test/resources/empty.servers.yaml b/test/resources/empty.servers.yaml index 4fbbbf28..621c6430 100644 --- a/test/resources/empty.servers.yaml +++ b/test/resources/empty.servers.yaml @@ -91,3 +91,4 @@ components: format: int32 message: type: string + diff --git a/test/resources/eov-operations.modulepath.yaml b/test/resources/eov-operations.modulepath.yaml index 1719a835..8b0ca08c 100644 --- a/test/resources/eov-operations.modulepath.yaml +++ b/test/resources/eov-operations.modulepath.yaml @@ -14,7 +14,7 @@ paths: get: description: | ping then pong! - operationId: ping.ping + operationId: ping.ping responses: '200': description: OK @@ -191,7 +191,7 @@ paths: summary: Get info about a User operationId: user.info security: [] - parameters: + parameters: - $ref: '#/components/parameters/userID' responses: '200': @@ -210,7 +210,7 @@ components: name: userID in: path required: true - schema: + schema: $ref: '#/components/schemas/UserID' # type: number diff --git a/test/resources/eov-operations.yaml b/test/resources/eov-operations.yaml index 9c641f3d..5f8906e4 100644 --- a/test/resources/eov-operations.yaml +++ b/test/resources/eov-operations.yaml @@ -15,8 +15,8 @@ paths: description: | ping then pong! # use operationId, (x-eov-operation-id is optional. it can be used in place of operationId or to override it) - operationId: ping - x-eov-operation-handler: routes/ping + operationId: ping + x-eov-operation-handler: routes/ping responses: '200': description: OK diff --git a/test/resources/escaped.characters.in.path.yaml b/test/resources/escaped.characters.in.path.yaml index e2d9544c..7a34bfd0 100644 --- a/test/resources/escaped.characters.in.path.yaml +++ b/test/resources/escaped.characters.in.path.yaml @@ -1,11 +1,11 @@ openapi: '3.0.0' info: - description: 'Some escaped characters in $ref' - version: '1.0.0' - title: 'Source Code' + description: "Some escaped characters in $ref" + version: "1.0.0" + title: "Source Code" license: - name: 'GPL-3.0-or-later' - url: 'https://choosealicense.com/licenses/gpl-3.0/' + name: "GPL-3.0-or-later" + url: "https://choosealicense.com/licenses/gpl-3.0/" servers: - url: /v1/ @@ -32,4 +32,4 @@ components: description: Explanation about an error required: - message - - errors + - errors \ No newline at end of file diff --git a/test/resources/formats.yaml b/test/resources/formats.yaml index 4dc9e9fa..6a29dc14 100644 --- a/test/resources/formats.yaml +++ b/test/resources/formats.yaml @@ -7,7 +7,7 @@ servers: paths: /fees: get: - parameters: + parameters: - name: id in: query required: true @@ -26,7 +26,7 @@ paths: /formats/1: get: - parameters: + parameters: - name: string_id in: query schema: @@ -56,3 +56,4 @@ paths: responses: '200': description: response + diff --git a/test/resources/headers.yaml b/test/resources/headers.yaml index e974b208..3859efbf 100644 --- a/test/resources/headers.yaml +++ b/test/resources/headers.yaml @@ -12,7 +12,7 @@ servers: paths: /headers_1: get: - operationId: ping + operationId: ping parameters: - name: x-userid in: header @@ -27,4 +27,4 @@ paths: text/plain: schema: type: string - example: headers_1 + example: headers_1 \ No newline at end of file diff --git a/test/resources/ignore.paths.yaml b/test/resources/ignore.paths.yaml index da4e151f..f2142f91 100644 --- a/test/resources/ignore.paths.yaml +++ b/test/resources/ignore.paths.yaml @@ -1,4 +1,4 @@ -openapi: '3.0.0' +openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore @@ -22,7 +22,7 @@ paths: schema: type: string responses: - '200': + "200": description: user response /pets/{id}: @@ -38,12 +38,12 @@ paths: type: integer format: int64 responses: - '200': + "200": description: pet response content: application/json: schema: - $ref: '#/components/schemas/Pet' + $ref: "#/components/schemas/Pet" /route_defined_in_openapi_only: get: @@ -56,7 +56,7 @@ paths: type: integer format: int64 responses: - '200': + "200": description: test components: diff --git a/test/resources/multipart.yaml b/test/resources/multipart.yaml index 765b1324..64592f8a 100644 --- a/test/resources/multipart.yaml +++ b/test/resources/multipart.yaml @@ -1,4 +1,4 @@ -openapi: '3.0.0' +openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore @@ -40,7 +40,7 @@ paths: p2: type: string responses: - '200': + "200": description: form data /sample_2: @@ -73,7 +73,7 @@ paths: form_p2: type: string responses: - '200': + "200": description: form data /sample_3: @@ -87,7 +87,7 @@ paths: type: string format: binary responses: - '200': + "200": description: binary /sample_4: @@ -153,7 +153,7 @@ paths: minimum: 5 maximum: 10 responses: - '200': + "200": description: form data components: diff --git a/test/resources/multiple-validations.yaml b/test/resources/multiple-validations.yaml index 6973d8ec..ed6a8bcc 100644 --- a/test/resources/multiple-validations.yaml +++ b/test/resources/multiple-validations.yaml @@ -11,7 +11,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Person' + $ref: "#/components/schemas/Person" responses: 200: description: Success @@ -38,7 +38,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Person' + $ref: "#/components/schemas/Person" components: schemas: diff --git a/test/resources/nested.routes.yaml b/test/resources/nested.routes.yaml index e4e87234..4e0450ca 100644 --- a/test/resources/nested.routes.yaml +++ b/test/resources/nested.routes.yaml @@ -69,4 +69,4 @@ components: type: integer format: int32 message: - type: string + type: string \ No newline at end of file diff --git a/test/resources/one.of.2.yaml b/test/resources/one.of.2.yaml index 5e9967c2..d954633f 100644 --- a/test/resources/one.of.2.yaml +++ b/test/resources/one.of.2.yaml @@ -104,7 +104,7 @@ components: # add CatObject as an option # so that the non-mapping / implied mapping tests can pass enum: [cat, kitty, CatObject] - color: + color: type: string default: gray @@ -118,7 +118,7 @@ components: discriminator: propertyName: pet_type - Dog: # "Dog" is a value for the pet_type property (the discriminator value) + Dog: # "Dog" is a value for the pet_type property (the discriminator value) allOf: # Combines the main `Pet` schema with `Dog`-specific properties - $ref: '#/components/schemas/Pet' - type: object @@ -129,7 +129,7 @@ components: breed: type: string enum: [Dingo, Husky, Retriever, Shepherd] - Cat: # "Cat" is a value for the pet_type property (the discriminator value) + Cat: # "Cat" is a value for the pet_type property (the discriminator value) allOf: # Combines the main `Pet` schema with `Cat`-specific properties - $ref: '#/components/schemas/Pet' - type: object @@ -138,4 +138,4 @@ components: hunts: type: boolean age: - type: integer + type: integer \ No newline at end of file diff --git a/test/resources/one.of.yaml b/test/resources/one.of.yaml index 88ebf659..cf638026 100644 --- a/test/resources/one.of.yaml +++ b/test/resources/one.of.yaml @@ -1,4 +1,4 @@ -openapi: '3.0.2' +openapi: "3.0.2" info: version: 1.0.0 title: requestBodies $ref @@ -15,17 +15,17 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/OneOfType' + $ref: "#/components/schemas/OneOfType" responses: - '200': + "200": description: OK content: application/json: schema: $ref: '#/components/schemas/OneOfType' - '400': + "400": description: Bad Request - + /one_of_b: post: requestBody: @@ -33,22 +33,22 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/OneOfTypeB' + $ref: "#/components/schemas/OneOfTypeB" responses: - '200': + "200": description: OK content: application/json: schema: $ref: '#/components/schemas/OneOfType' - '400': + "400": description: Bad Request components: schemas: SimilarTypeOne: allOf: - - $ref: '#/components/schemas/SimilarSuperType' + - $ref: "#/components/schemas/SimilarSuperType" - type: object properties: type: @@ -63,7 +63,7 @@ components: SimilarTypeTwo: allOf: - - $ref: '#/components/schemas/SimilarSuperType' + - $ref: "#/components/schemas/SimilarSuperType" - type: object properties: type: @@ -83,14 +83,14 @@ components: type: array items: oneOf: - - $ref: '#/components/schemas/SimilarTypeOne' - - $ref: '#/components/schemas/SimilarTypeTwo' + - $ref: "#/components/schemas/SimilarTypeOne" + - $ref: "#/components/schemas/SimilarTypeTwo" discriminator: propertyName: type SimilarTypeOneB: allOf: - - $ref: '#/components/schemas/SimilarSuperTypeB' + - $ref: "#/components/schemas/SimilarSuperTypeB" properties: type: type: string @@ -101,7 +101,7 @@ components: value: type: number format: int32 - enum: [1] + enum: [ 1 ] default: 1 required: - type @@ -110,7 +110,7 @@ components: SimilarTypeTwoB: allOf: - - $ref: '#/components/schemas/SimilarSuperTypeB' + - $ref: "#/components/schemas/SimilarSuperTypeB" properties: type: type: string @@ -121,7 +121,7 @@ components: value: type: number format: int32 - enum: [2] + enum: [ 2 ] default: 2 required: - type @@ -135,8 +135,8 @@ components: type: array items: oneOf: - - $ref: '#/components/schemas/SimilarTypeOneB' - - $ref: '#/components/schemas/SimilarTypeTwoB' + - $ref: "#/components/schemas/SimilarTypeOneB" + - $ref: "#/components/schemas/SimilarTypeTwoB" discriminator: propertyName: type @@ -145,7 +145,7 @@ components: properties: id: type: string - + SimilarSuperTypeB: type: object properties: @@ -158,3 +158,4 @@ components: propertyName: type required: - value + diff --git a/test/resources/openapi.json b/test/resources/openapi.json index dc65d468..bc123cc9 100644 --- a/test/resources/openapi.json +++ b/test/resources/openapi.json @@ -1,539 +1,578 @@ { - "openapi": "3.0.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification", - "termsOfService": "http://swagger.io/terms/", - "contact": { - "name": "Swagger API Team", - "email": "apiteam@swagger.io", - "url": "http://swagger.io" - }, - "license": { - "name": "Apache 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "servers": [ - { - "url": "/v1/" - }, - { - "url": "http://{name}.swagger.io:{port}/{version}", - "variables": { - "name": { - "default": "petstore", - "enum": ["petstore", "storeofpets"] - }, - "port": { - "enum": ["443", "8443"], - "default": "443" - }, - "version": { - "default": "v1", - "enum": ["v1", "v2"] - } - } - } - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", - "operationId": "findPets", - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "required": false, - "style": "form", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "required": true, - "schema": { - "type": "integer", - "format": "int32", - "minimum": 5 - } - }, - { - "name": "test", - "in": "query", - "description": "maximum number of results to return", - "required": true, - "schema": { - "type": "string", - "enum": ["one", "two"] - } - }, - { - "name": "testJson", - "in": "query", - "description": "JSON in query params", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string", - "enum": ["bar", "baz"] - } - } - } - } - } - }, - { - "name": "testArrayNoExplode", - "in": "query", - "description": "Array in query param", - "schema": { - "type": "array", - "items": { - "type": "string", - "enum": ["foo", "bar", "baz"] - } - }, - "style": "form", - "explode": false - }, - { - "name": "testArrayNoExplode2", - "in": "query", - "description": "Array in query param", - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "style": "form", - "explode": false - }, - { - "name": "testArrayExplode", - "in": "query", - "description": "Array explode in query param", - "schema": { - "type": "array", - "items": { - "type": "string", - "enum": ["foo", "bar", "baz"] - } - }, - "style": "form", - "explode": true - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "requestBody": { - "description": "Pet to add to the store", - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/NewPet" - } - } - } - }, - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "find pet by id", - "parameters": [ - { - "$ref": "#/components/parameters/id" - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/pets/{id}/photos": { - "post": { - "description": "upload a photo of the pet", - "operationId": "uploadPetPhoto", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "required": ["file", "metadata"], - "properties": { - "file": { - "description": "The photo", - "type": "string", - "format": "binary" - }, - "metadata": { - "type": "string" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "photo uploaded" - } - } - } - }, - "/pets/{id}/attributes": { - "get": { - "description": "Returns attributes for this pet", - "operationId": "find attributes", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "in": "header", - "name": "X-Attribute-Id", - "schema": { - "type": "string", - "format": "uuid" - }, - "required": true - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Attribute" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/pets/{id}/attributes/{attribute_id}": { - "get": { - "description": "Returns the attribute specified by attribute_id", - "operationId": "find attributes by pet id", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "in": "path", - "name": "attribute_id", - "schema": { - "type": "integer", - "format": "int64" - }, - "required": true - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Attribute" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/route_not_defined_within_express": { - "get": { - "description": "Returns attributes for this pet", - "operationId": "route-not-defined-within-express", - "parameters": [ - { - "name": "name", - "in": "query", - "description": "the name", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Attribute" - } - } - } - }, - "default": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - } - }, - "components": { - "parameters": { - "id": { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - }, - "schemas": { - "NewPet": { - "required": ["name"], - "properties": { - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "Pet": { - "allOf": [ - { - "$ref": "#/components/schemas/NewPet" - }, - { - "required": ["id"], - "properties": { - "id": { - "type": "integer", - "format": "int64" - } - } - } - ] - }, - "NewAttribute": { - "required": ["name"], - "properties": { - "name": { - "type": "string" - } - } - }, - "Attribute": { - "allOf": [ - { - "$ref": "#/components/schemas/NewAttribute" - }, - { - "required": ["id"], - "properties": { - "id": { - "type": "integer", - "format": "int64" - } - } - } - ] - }, - "NewPhoto": { - "type": "object", - "required": ["file"], - "properties": { - "file": { - "description": "The photo", - "type": "string", - "format": "binary" - } - } - }, - "Error": { - "required": ["code", "message"], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore", + "description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "Swagger API Team", + "email": "apiteam@swagger.io", + "url": "http://swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "servers": [ + { + "url": "/v1/" + }, + { + "url": "http://{name}.swagger.io:{port}/{version}", + "variables": { + "name": { + "default": "petstore", + "enum": [ + "petstore", + "storeofpets" + ] + }, + "port": { + "enum": [ + "443", + "8443" + ], + "default": "443" + }, + "version": { + "default": "v1", + "enum": [ + "v1", + "v2" + ] + } + } + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "required": false, + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "required": true, + "schema": { + "type": "integer", + "format": "int32", + "minimum": 5 + } + }, + { + "name": "test", + "in": "query", + "description": "maximum number of results to return", + "required": true, + "schema": { + "type": "string", + "enum": [ + "one", + "two" + ] + } + }, + { + "name": "testJson", + "in": "query", + "description": "JSON in query params", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "foo": { + "type": "string", + "enum": [ + "bar", + "baz" + ] + } + } + } + } + } + }, + { + "name": "testArrayNoExplode", + "in": "query", + "description": "Array in query param", + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "foo", + "bar", + "baz" + ] + } + }, + "style": "form", + "explode": false + }, + { + "name": "testArrayNoExplode2", + "in": "query", + "description": "Array in query param", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "style": "form", + "explode": false + }, + { + "name": "testArrayExplode", + "in": "query", + "description": "Array explode in query param", + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "foo", + "bar", + "baz" + ] + } + }, + "style": "form", + "explode": true + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NewPet" + } + } + } + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "find pet by id", + "parameters": [ + { + "$ref": "#/components/parameters/id" + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/pets/{id}/photos": { + "post": { + "description": "upload a photo of the pet", + "operationId": "uploadPetPhoto", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "required": [ + "file", + "metadata" + ], + "properties": { + "file": { + "description": "The photo", + "type": "string", + "format": "binary" + }, + "metadata": { + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "photo uploaded" + } + } + } + }, + "/pets/{id}/attributes": { + "get": { + "description": "Returns attributes for this pet", + "operationId": "find attributes", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "in": "header", + "name": "X-Attribute-Id", + "schema": { + "type": "string", + "format": "uuid" + }, + "required": true + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Attribute" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/pets/{id}/attributes/{attribute_id}": { + "get": { + "description": "Returns the attribute specified by attribute_id", + "operationId": "find attributes by pet id", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "in": "path", + "name": "attribute_id", + "schema": { + "type": "integer", + "format": "int64" + }, + "required": true + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Attribute" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/route_not_defined_within_express": { + "get": { + "description": "Returns attributes for this pet", + "operationId": "route-not-defined-within-express", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Attribute" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + } + }, + "components": { + "parameters": { + "id": { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + }, + "schemas": { + "NewPet": { + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "Pet": { + "allOf": [ + { + "$ref": "#/components/schemas/NewPet" + }, + { + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + ] + }, + "NewAttribute": { + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + } + } + }, + "Attribute": { + "allOf": [ + { + "$ref": "#/components/schemas/NewAttribute" + }, + { + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + ] + }, + "NewPhoto": { + "type": "object", + "required": [ + "file" + ], + "properties": { + "file": { + "description": "The photo", + "type": "string", + "format": "binary" + } + } + }, + "Error": { + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } } diff --git a/test/resources/openapi.yaml b/test/resources/openapi.yaml index d2470789..c5343611 100644 --- a/test/resources/openapi.yaml +++ b/test/resources/openapi.yaml @@ -115,7 +115,7 @@ paths: - bar - baz style: form - # explode: true +# explode: true responses: '200': description: pet response diff --git a/test/resources/path.order.yaml b/test/resources/path.order.yaml index 7b660c30..b6578542 100644 --- a/test/resources/path.order.yaml +++ b/test/resources/path.order.yaml @@ -1,4 +1,4 @@ -openapi: '3.0.0' +openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore @@ -22,12 +22,12 @@ paths: schema: type: string responses: - '200': + "200": description: user response content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" /users/jimmy: post: @@ -38,14 +38,14 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" responses: - '200': + "200": description: user response content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" components: schemas: diff --git a/test/resources/path.params.yaml b/test/resources/path.params.yaml index 22d7a29b..014afadc 100644 --- a/test/resources/path.params.yaml +++ b/test/resources/path.params.yaml @@ -1,7 +1,7 @@ -openapi: '3.0.0' +openapi: "3.0.0" info: - title: 'Test for allOf' - version: '1' + title: "Test for allOf" + version: "1" servers: - url: /v1/ paths: @@ -15,11 +15,11 @@ paths: type: string responses: 200: - description: '' + description: "" content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" /users_alt/{id}: parameters: - name: id @@ -30,11 +30,11 @@ paths: get: responses: 200: - description: '' + description: "" content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" /multi_users/{ids}: get: summary: Deletes Features given a number of uuids. @@ -48,13 +48,13 @@ paths: type: string style: simple responses: - '200': + "200": description: Features were successfully deleted content: application/json: schema: type: object - '/user_lookup:{name}': + "/user_lookup:{name}": get: parameters: - name: name @@ -64,15 +64,15 @@ paths: type: string responses: 200: - description: '' + description: "" content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" components: schemas: User: type: object properties: id: - type: 'string' + type: "string" diff --git a/test/resources/query.params.yaml b/test/resources/query.params.yaml index 491a041b..599552d7 100644 --- a/test/resources/query.params.yaml +++ b/test/resources/query.params.yaml @@ -44,7 +44,7 @@ paths: /allow_reserved: get: parameters: - - name: value + - name: value in: query required: true schema: @@ -57,7 +57,7 @@ paths: /allow_reserved/array_explode: get: parameters: - - name: value + - name: value in: query required: true schema: diff --git a/test/resources/query.serialization.yaml b/test/resources/query.serialization.yaml index 63d0139b..5ffb5d24 100644 --- a/test/resources/query.serialization.yaml +++ b/test/resources/query.serialization.yaml @@ -6,7 +6,7 @@ info: paths: /api/q_form_explode: get: - parameters: + parameters: - description: Description schema: title: State @@ -26,7 +26,7 @@ paths: /api/q_form_nexplode: get: - parameters: + parameters: - description: Description required: false explode: false @@ -37,7 +37,7 @@ paths: $ref: '#/components/schemas/Foo' description: A description name: state - in: query + in: query responses: 200: description: OK @@ -45,7 +45,8 @@ paths: 'application/json; charset=utf-8': schema: type: object - + + components: schemas: Foo: @@ -53,3 +54,5 @@ components: enum: - on - off + + \ No newline at end of file diff --git a/test/resources/read.only.yaml b/test/resources/read.only.yaml index 23978698..ffc5670f 100644 --- a/test/resources/read.only.yaml +++ b/test/resources/read.only.yaml @@ -145,11 +145,11 @@ paths: application/json: schema: $ref: '#/components/schemas/ProductNested' - + /readonly_required_allof: post: description: readonly required - parameters: + parameters: - name: include_id in: query schema: @@ -162,7 +162,7 @@ paths: schema: type: object properties: - optional: + optional: type: string responses: '200': diff --git a/test/resources/response.object.serializer.yaml b/test/resources/response.object.serializer.yaml index 955bc081..dce9c369 100644 --- a/test/resources/response.object.serializer.yaml +++ b/test/resources/response.object.serializer.yaml @@ -1,7 +1,7 @@ -openapi: '3.0.0' +openapi: "3.0.0" info: - title: 'Test for allOf' - version: '1' + title: "Test for allOf" + version: "1" servers: - url: /v1/ paths: @@ -59,7 +59,7 @@ components: User: type: object properties: - id: + id: type: number created_at: - $ref: '#/components/schemas/Date' + $ref: "#/components/schemas/Date" diff --git a/test/resources/response.validation.defaults.yaml b/test/resources/response.validation.defaults.yaml index 0f532ebb..518adc85 100644 --- a/test/resources/response.validation.defaults.yaml +++ b/test/resources/response.validation.defaults.yaml @@ -5,38 +5,38 @@ info: servers: - url: /v1 paths: - /default_inline: - get: - parameters: - - name: q - in: 'query' - required: true - schema: - type: string - responses: - '200': - description: Success - content: - 'application/json': - schema: - type: object - properties: - data: - description: Some data - type: string - required: - - data - default: - description: Unexpected error - content: - 'application/json': - schema: - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string + /default_inline: + get: + parameters: + - name: q + in: 'query' + required: true + schema: + type: string + responses: + '200': + description: Success + content: + 'application/json': + schema: + type: object + properties: + data: + description: Some data + type: string + required: + - data + default: + description: Unexpected error + content: + 'application/json': + schema: + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string \ No newline at end of file diff --git a/test/resources/response.validation.yaml b/test/resources/response.validation.yaml index e26437d6..550c4b8e 100644 --- a/test/resources/response.validation.yaml +++ b/test/resources/response.validation.yaml @@ -49,7 +49,7 @@ paths: responses: '204': description: empty - + /boolean: description: get boolean responses get: diff --git a/test/resources/routes/pets.js b/test/resources/routes/pets.js index 7e85650b..3b3e8be0 100644 --- a/test/resources/routes/pets.js +++ b/test/resources/routes/pets.js @@ -24,7 +24,7 @@ module.exports = { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map((f) => ({ + files_metadata: req.files.map(f => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, @@ -55,7 +55,7 @@ module.exports = { console.log(req.files); res.status(201).json({ - files_metadata: req.files.map((f) => ({ + files_metadata: req.files.map(f => ({ originalname: f.originalname, encoding: f.encoding, mimetype: f.mimetype, diff --git a/test/resources/routes/user.js b/test/resources/routes/user.js index b51c5dae..9edb0b58 100644 --- a/test/resources/routes/user.js +++ b/test/resources/routes/user.js @@ -1,3 +1,3 @@ module.exports = { - info: (req, res) => res.status(200).send({ id: req.params.userID }), + info: (req, res) => res.status(200).send({ id: req.params.userID }) }; diff --git a/test/resources/security.top.level.yaml b/test/resources/security.top.level.yaml index 5fa4d6ea..7f6e9534 100644 --- a/test/resources/security.top.level.yaml +++ b/test/resources/security.top.level.yaml @@ -43,7 +43,7 @@ paths: get: security: - ApiKeyQueryAuth: [] - parameters: + parameters: - name: param1 in: query schema: diff --git a/test/resources/security.yaml b/test/resources/security.yaml index cb49385a..3e6d2c66 100644 --- a/test/resources/security.yaml +++ b/test/resources/security.yaml @@ -1,4 +1,4 @@ -openapi: '3.0.2' +openapi: "3.0.2" info: version: 1.0.0 title: requestBodies $ref @@ -15,15 +15,15 @@ paths: BearerAuth: [] - BasicAuth: [] responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized /no_security: get: responses: - '200': + "200": description: OK /api_key: @@ -31,9 +31,9 @@ paths: security: - ApiKeyAuth: [] responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized /api_key_or_anonymous: @@ -43,9 +43,9 @@ paths: - {} - ApiKeyAuth: [] responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized # This api key with scopes should fail validation and return 500 @@ -53,11 +53,11 @@ paths: /api_key_with_scopes: get: security: - - ApiKeyAuth: ['read', 'write'] + - ApiKeyAuth: ["read", "write"] responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized /bearer: @@ -65,9 +65,9 @@ paths: security: - BearerAuth: [] responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized /basic: @@ -75,9 +75,9 @@ paths: security: - BasicAuth: [] responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized /cookie_auth: @@ -85,9 +85,9 @@ paths: security: - CookieAuth: [] responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized /multi_auth: @@ -98,9 +98,9 @@ paths: - BasicAuth: [] CookieAuth: [] responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized /oauth2: @@ -110,9 +110,9 @@ paths: - scope1 - scope2 responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized /openid: @@ -122,9 +122,9 @@ paths: - scope1 - scope2 responses: - '200': + "200": description: OK - '401': + "401": description: unauthorized components: diff --git a/test/resources/serdes.yaml b/test/resources/serdes.yaml index 41e1f48a..6a4f29ed 100644 --- a/test/resources/serdes.yaml +++ b/test/resources/serdes.yaml @@ -1,7 +1,7 @@ -openapi: '3.0.0' +openapi: "3.0.0" info: - title: 'Test for allOf' - version: '1' + title: "Test for allOf" + version: "1" servers: - url: /v1/ paths: @@ -12,7 +12,7 @@ paths: in: path required: true schema: - $ref: '#/components/schemas/ObjectId' + $ref: "#/components/schemas/ObjectId" - name: date-time-from-inline in: query required: false @@ -23,7 +23,7 @@ paths: in: query required: false schema: - $ref: '#/components/schemas/DateTime' + $ref: "#/components/schemas/DateTime" - name: baddateresponse in: query schema: @@ -33,15 +33,15 @@ paths: in: query required: false schema: - $ref: '#/components/schemas/ShortOrLong' + $ref: "#/components/schemas/ShortOrLong" responses: 200: - description: '' + description: "" content: application/json: schema: allOf: - - $ref: '#/components/schemas/User' + - $ref: "#/components/schemas/User" - type: object properties: summary: @@ -56,7 +56,7 @@ paths: /users: post: requestBody: - content: + content : application/json: schema: allOf: @@ -68,12 +68,12 @@ paths: format: date-time responses: 200: - description: '' + description: "" content: application/json: schema: allOf: - - $ref: '#/components/schemas/User' + - $ref: "#/components/schemas/User" - type: object properties: summary: @@ -110,12 +110,12 @@ components: type: object properties: id: - $ref: '#/components/schemas/ObjectId' + $ref: "#/components/schemas/ObjectId" tags: - $ref: '#/components/schemas/StringList' + $ref: "#/components/schemas/StringList" creationDateTime: - $ref: '#/components/schemas/DateTime' + $ref: "#/components/schemas/DateTime" creationDate: - $ref: '#/components/schemas/Date' + $ref: "#/components/schemas/Date" shortOrLong: - $ref: '#/components/schemas/ShortOrLong' + $ref: "#/components/schemas/ShortOrLong" diff --git a/test/resources/serialized-deep-object.objects.yaml b/test/resources/serialized-deep-object.objects.yaml index 0517f3c6..4ede419f 100644 --- a/test/resources/serialized-deep-object.objects.yaml +++ b/test/resources/serialized-deep-object.objects.yaml @@ -1,4 +1,4 @@ -openapi: '3.0.2' +openapi: "3.0.2" info: version: 1.0.0 title: Request Query Serialization @@ -12,7 +12,7 @@ paths: x-vendorExtension1: accounts get: x-vendorExtension2: accounts - summary: 'retrieve a deep object' + summary: "retrieve a deep object" operationId: getDeepObject parameters: - in: query @@ -31,21 +31,21 @@ paths: minItems: 1 state: type: string - enum: ['default', 'validated', 'pending'] - default: 'default' + enum: ["default", "validated", "pending"] + default: "default" description: "Filter the tags by their validity. The default value ('default') stands for no filtering." greeting: type: string - default: 'hello' + default: "hello" responses: - '200': + "200": description: the object /deep_object_2: get: parameters: - - $ref: '#/components/parameters/pedestrian' + - $ref: '#/components/parameters/pedestrian' responses: - '200': + "200": description: the object components: @@ -76,7 +76,7 @@ components: # greeting: # type: string # default: "hello" - + parameters: pedestrian: name: pedestrian diff --git a/test/resources/serialized.objects.defaults.yaml b/test/resources/serialized.objects.defaults.yaml index cd892729..4cd9e9ec 100644 --- a/test/resources/serialized.objects.defaults.yaml +++ b/test/resources/serialized.objects.defaults.yaml @@ -2,8 +2,8 @@ components: schemas: PageSort: allOf: - - $ref: '#/components/schemas/Paging' - - $ref: '#/components/schemas/Sorting' + - $ref: "#/components/schemas/Paging" + - $ref: "#/components/schemas/Sorting" Paging: properties: page: @@ -47,10 +47,10 @@ paths: in: query name: pagesort schema: - $ref: '#/components/schemas/PageSort' + $ref: "#/components/schemas/PageSort" style: deepObject responses: - '200': + "200": description: description content: application/json: diff --git a/test/resources/serialized.objects.yaml b/test/resources/serialized.objects.yaml index 8c36004b..bdf62637 100644 --- a/test/resources/serialized.objects.yaml +++ b/test/resources/serialized.objects.yaml @@ -1,4 +1,4 @@ -openapi: '3.0.2' +openapi: "3.0.2" info: version: 1.0.0 title: Request Query Serialization @@ -12,7 +12,7 @@ paths: x-vendorExtension1: accounts get: x-vendorExtension2: accounts - summary: 'retrieve a deep object' + summary: "retrieve a deep object" operationId: getDeepObject parameters: - in: query @@ -30,19 +30,19 @@ paths: minItems: 1 state: type: string - enum: ['default', 'validated', 'pending'] - default: 'default' + enum: ["default", "validated", "pending"] + default: "default" description: "Filter the tags by their validity. The default value ('default') stands for no filtering." greeting: type: string - default: 'hello' + default: "hello" responses: - '200': + "200": description: the object /deep_object_2: get: - summary: 'retrieve a deep object' + summary: "retrieve a deep object" operationId: getDeepObject2 parameters: - in: query @@ -52,11 +52,11 @@ paths: schema: $ref: '#/components/schemas/Deep' responses: - '200': + "200": description: the object /tags: get: - summary: 'Retrieve all tags' + summary: "Retrieve all tags" operationId: getTags parameters: - in: query @@ -74,15 +74,15 @@ paths: minItems: 1 state: type: string - enum: ['default', 'validated', 'pending'] - default: 'default' + enum: ["default", "validated", "pending"] + default: "default" description: "Filter the tags by their validity. The default value ('default') stands for no filtering." responses: - '200': - description: 'An array of tag' + "200": + description: "An array of tag" /serialisable: get: - summary: 'Retrieve something' + summary: "Retrieve something" parameters: - in: query style: form @@ -109,7 +109,7 @@ paths: description: Should not be serialized schema: description: Value passed to Javascript's `new Date()`. - example: '2019-06-24T12:34:56.789Z' + example: "2019-06-24T12:34:56.789Z" anyOf: - type: integer description: Unix milliseconds @@ -134,7 +134,7 @@ paths: required: - foo responses: - '200': + "200": description: parsed & validated query params content: application/json: @@ -143,7 +143,7 @@ paths: components: schemas: - Deep: + Deep: type: object properties: tag_ids: @@ -154,9 +154,9 @@ components: minItems: 1 state: type: string - enum: ['default', 'validated', 'pending'] - default: 'default' + enum: ["default", "validated", "pending"] + default: "default" description: "Filter the tags by their validity. The default value ('default') stands for no filtering." greeting: type: string - default: 'hello' + default: "hello" diff --git a/test/resources/servers.1.yaml b/test/resources/servers.1.yaml index 11d3a218..eeed9719 100644 --- a/test/resources/servers.1.yaml +++ b/test/resources/servers.1.yaml @@ -18,7 +18,7 @@ servers: paths: /ping: get: - parameters: + parameters: - name: id in: query required: true diff --git a/test/resources/servers.2.yaml b/test/resources/servers.2.yaml index 77e6c3e8..bdd805a2 100644 --- a/test/resources/servers.2.yaml +++ b/test/resources/servers.2.yaml @@ -18,7 +18,7 @@ servers: paths: /ping: get: - parameters: + parameters: - name: id in: query required: true diff --git a/test/resources/services/index.js b/test/resources/services/index.js index d7822814..1c7afd6e 100644 --- a/test/resources/services/index.js +++ b/test/resources/services/index.js @@ -24,11 +24,11 @@ module.exports.Pets = class { this.id = 4; } findAll({ type, limit }) { - return data.filter((d) => d.type === type).slice(0, limit); + return data.filter(d => d.type === type).slice(0, limit); } findById(id) { - return data.filter((p) => p.id === id)[0]; + return data.filter(p => p.id === id)[0]; } create(pet) { @@ -38,6 +38,6 @@ module.exports.Pets = class { } delete(id) { - return data.filter((e) => e.id !== id); + return data.filter(e => e.id !== id); } -}; +} diff --git a/test/resources/sub_files/paths/auth.yaml b/test/resources/sub_files/paths/auth.yaml index 50ce1f2c..d5860cf4 100644 --- a/test/resources/sub_files/paths/auth.yaml +++ b/test/resources/sub_files/paths/auth.yaml @@ -1,7 +1,7 @@ paths: /auth/login: post: - summary: 'Logs user into the system' + summary: "Logs user into the system" operationId: signIn tags: - guest @@ -10,7 +10,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Auth' + $ref: "#/components/schemas/Auth" responses: '200': description: A JSON containing the JWT Token and some information about the user @@ -18,7 +18,7 @@ paths: application/json: schema: allOf: - - $ref: '#/components/schemas/JWTToken' + - $ref: "#/components/schemas/JWTToken" - type: object description: Some basic information on this user properties: @@ -27,14 +27,14 @@ paths: properties: fullName: type: string - description: 'The full name of this user' - example: 'Eric Cartman' + description: "The full name of this user" + example: "Eric Cartman" minLength: 1 maxLength: 50 role: type: string enum: [admin, user] - description: 'What kind of user are we ?' + description: "What kind of user are we ?" required: - fullName - role @@ -42,14 +42,14 @@ paths: - user # Definition of all error statuses default: - description: 'Whatever error : 4XX - Client error (Bad Request, Unauthorized, etc.) , 5XX - Server error' + description: "Whatever error : 4XX - Client error (Bad Request, Unauthorized, etc.) , 5XX - Server error" content: application/json: schema: - $ref: '#/components/schemas/ErrorObject' + $ref: "#/components/schemas/ErrorObject" /auth/register: post: - summary: 'Creates a new user into the system' + summary: "Creates a new user into the system" operationId: register tags: - guest @@ -59,13 +59,13 @@ paths: application/json: schema: allOf: - - $ref: '#/components/schemas/Auth' + - $ref: "#/components/schemas/Auth" - type: object properties: fullName: type: string - example: 'Some User' - description: 'The full name of this new user' + example: "Some User" + description: "The full name of this new user" minLength: 1 maxLength: 50 required: @@ -75,11 +75,11 @@ paths: description: OK # Definition of all error statuses default: - description: 'Whatever error : 4XX - Client error (Bad Request, Unauthorized, etc.) , 5XX - Server error' + description: "Whatever error : 4XX - Client error (Bad Request, Unauthorized, etc.) , 5XX - Server error" content: application/json: schema: - $ref: '#/components/schemas/ErrorObject' + $ref: "#/components/schemas/ErrorObject" components: schemas: @@ -89,11 +89,11 @@ components: email: type: string format: email - example: 'jy95@perdu.com' + example: "jy95@perdu.com" password: type: string format: password - example: '42' + example: "42" required: - email - password @@ -118,4 +118,4 @@ components: description: Explanation about an error required: - message - - errors + - errors \ No newline at end of file diff --git a/test/resources/unknown.formats.yaml b/test/resources/unknown.formats.yaml index 82acca03..95735e5c 100644 --- a/test/resources/unknown.formats.yaml +++ b/test/resources/unknown.formats.yaml @@ -3,7 +3,7 @@ info: title: Formats version: 1.0.0 servers: - - url: /v1 +- url: /v1 paths: /persons: post: @@ -16,11 +16,12 @@ paths: 200: description: Invalid ID supplied + components: schemas: Person: required: - - id + - id type: object properties: id: @@ -31,4 +32,4 @@ components: hypertext: type: string format: hypertext - example: '

Hello. I am...' + example: "

Hello. I am..." \ No newline at end of file diff --git a/test/resources/unknown.keywords.yaml b/test/resources/unknown.keywords.yaml index 9938f5eb..b254d601 100644 --- a/test/resources/unknown.keywords.yaml +++ b/test/resources/unknown.keywords.yaml @@ -3,7 +3,7 @@ info: title: Keywords version: 1.0.0 servers: - - url: /v1 +- url: /v1 paths: /persons: post: @@ -21,7 +21,7 @@ components: schemas: Person: required: - - id + - id type: object x-custom-keyword: Ignored by validator. properties: diff --git a/test/resources/wildcard.path.params.yaml b/test/resources/wildcard.path.params.yaml index b84b50e8..13bf3a4a 100644 --- a/test/resources/wildcard.path.params.yaml +++ b/test/resources/wildcard.path.params.yaml @@ -3,7 +3,7 @@ info: title: dummy api version: 1.0.0 servers: - - url: /v1 +- url: /v1 paths: /d1/{id}: @@ -91,4 +91,4 @@ paths: responses: 200: description: dummy response - content: {} + content: {} \ No newline at end of file diff --git a/test/resources/write.only.yaml b/test/resources/write.only.yaml index 9868f07d..cf8d62e1 100644 --- a/test/resources/write.only.yaml +++ b/test/resources/write.only.yaml @@ -15,7 +15,7 @@ paths: post: description: create products operationId: createProductsInline - parameters: + parameters: - name: exclude_write_only in: query schema: @@ -50,7 +50,7 @@ paths: post: description: create products operationId: createProductsNested - parameters: + parameters: - name: exclude_write_only in: query schema: @@ -96,7 +96,7 @@ components: ProductNested: type: object required: - - 'password' + - "password" properties: id: type: string @@ -126,7 +126,7 @@ components: Review: type: object required: - - 'review_password' + - "review_password" properties: id: type: integer diff --git a/test/resources/xt.newpet.yaml b/test/resources/xt.newpet.yaml index 86bea101..971d0750 100644 --- a/test/resources/xt.newpet.yaml +++ b/test/resources/xt.newpet.yaml @@ -7,4 +7,4 @@ NewPet: type: string nullable: true tag: - type: string + type: string \ No newline at end of file diff --git a/test/resources/xt.openapi.parameters.yaml b/test/resources/xt.openapi.parameters.yaml index a262f7d1..105f04c9 100644 --- a/test/resources/xt.openapi.parameters.yaml +++ b/test/resources/xt.openapi.parameters.yaml @@ -6,4 +6,4 @@ parameters: required: true schema: type: integer - format: int64 + format: int64 \ No newline at end of file diff --git a/test/response.object.serializer.spec.ts b/test/response.object.serializer.spec.ts index 3d0b13d5..ffffeb6c 100644 --- a/test/response.object.serializer.spec.ts +++ b/test/response.object.serializer.spec.ts @@ -31,12 +31,10 @@ describe('response serializer', () => { app.get([`${app.basePath}/array-of-date-times`], (req, res) => { let date = new Date('2020-12-20T07:28:19.213Z'); res.json({ - users: [ - { - id: req.params.id, - created_at: date, - }, - ], + users: [{ + id: req.params.id, + created_at: date, + }], }); }); app.get([`${app.basePath}/date`], (req, res) => { @@ -82,9 +80,7 @@ describe('response serializer', () => { .get(`${app.basePath}/array-of-date-times`) .expect(200) .then((r) => { - expect(r.body.users[0].created_at).to.equal( - '2020-12-20T07:28:19.213Z', - ); + expect(r.body.users[0].created_at).to.equal('2020-12-20T07:28:19.213Z'); })); }); }); diff --git a/test/response.validation.coerce.types.spec.ts b/test/response.validation.coerce.types.spec.ts index b36c14e1..f13108a1 100644 --- a/test/response.validation.coerce.types.spec.ts +++ b/test/response.validation.coerce.types.spec.ts @@ -48,5 +48,7 @@ describe('response validation with type coercion', () => { expect(r.body).to.equal(true); })); it('should coerce id from string to number', async () => - request(app).get(`${app.basePath}/object`).expect(200)); + request(app) + .get(`${app.basePath}/object`) + .expect(200)); }); diff --git a/test/response.validation.on.error.spec.ts b/test/response.validation.on.error.spec.ts index 465a9a38..36ad9643 100644 --- a/test/response.validation.on.error.spec.ts +++ b/test/response.validation.on.error.spec.ts @@ -16,16 +16,16 @@ describe(packageJson.name, () => { { apiSpec: apiSpecPath, validateResponses: { - onError: function (_err, body) { + onError: function(_err, body) { onErrorArgs = Array.from(arguments); if (body[0].id === 'bad_id_throw') { throw new Error('error in onError handler'); } - }, + } }, }, 3005, - (app) => { + app => { app.get(`${app.basePath}/users`, (_req, res) => { const json = ['user1', 'user2', 'user3']; return res.json(json); @@ -52,7 +52,7 @@ describe(packageJson.name, () => { afterEach(() => { onErrorArgs = null; - }); + }) after(() => { app.server.close(); @@ -66,12 +66,10 @@ describe(packageJson.name, () => { const data = [{ id: 'bad_id', name: 'name', tag: 'tag' }]; expect(r.body).to.eql(data); expect(onErrorArgs.length).to.equal(3); - expect(onErrorArgs[0].message).to.equal( - '/response/0/id must be integer', - ); + expect(onErrorArgs[0].message).to.equal('/response/0/id must be integer'); expect(onErrorArgs[1]).to.eql(data); expect(onErrorArgs[2].query).to.eql({ - mode: 'bad_type', + mode: 'bad_type' }); })); @@ -92,9 +90,7 @@ describe(packageJson.name, () => { const data = [{ id: 'bad_id_throw', name: 'name', tag: 'tag' }]; expect(r.body.message).to.equal('error in onError handler'); expect(onErrorArgs.length).to.equal(3); - expect(onErrorArgs[0].message).to.equal( - '/response/0/id must be integer', - ); + expect(onErrorArgs[0].message).to.equal('/response/0/id must be integer'); expect(onErrorArgs[1]).to.eql(data); })); }); diff --git a/test/response.validator.spec.ts b/test/response.validator.spec.ts index 10c353bc..09b06c78 100644 --- a/test/response.validator.spec.ts +++ b/test/response.validator.spec.ts @@ -17,10 +17,10 @@ const fakeReq: OpenApiRequest = { describe(packageJson.name, () => { it('should validate the using default (in this case the error object)', async () => { const v = new ResponseValidator(cloneDeep(apiSpec), { - formats: { - 'date-time': true, - }, - strict: false, + formats: { + 'date-time': true, + }, + strict: false, }); const responses = petsResponseSchema(); const validators = v._getOrBuildValidator(fakeReq, responses); @@ -42,10 +42,10 @@ describe(packageJson.name, () => { it('should throw error when default response is invalid', async () => { const v = new ResponseValidator(apiSpec, { - formats: { - 'date-time': true, - }, - strict: false, + formats: { + 'date-time': true, + }, + strict: false, }); const responses = petsResponseSchema(); const validators = v._getOrBuildValidator(fakeReq, responses); @@ -71,10 +71,10 @@ describe(packageJson.name, () => { it('should return an error if field type is invalid', async () => { const v = new ResponseValidator(apiSpec, { - formats: { - 'date-time': true, - }, - strict: false, + formats: { + 'date-time': true, + }, + strict: false, }); const responses = petsResponseSchema(); const validators = v._getOrBuildValidator(fakeReq, responses); diff --git a/test/security.defaults.spec.ts b/test/security.defaults.spec.ts index 02019e80..18bbeee5 100644 --- a/test/security.defaults.spec.ts +++ b/test/security.defaults.spec.ts @@ -22,7 +22,7 @@ describe('security.defaults', () => { .get(`/bearer`, (req, res) => res.json({ logged_in: true })) .get(`/basic`, (req, res) => res.json({ logged_in: true })) .get('/no_security', (req, res) => res.json({ logged_in: true })) - .get('/multi_auth', (req, res) => res.json({ logged_in: true })), + .get('/multi_auth', (req, res) => res.json({ logged_in: true })) ); }); @@ -62,36 +62,36 @@ describe('security.defaults', () => { .then((r) => { expect(r.body) .to.have.property('message') - .that.equals("cookie 'JSESSIONID' required"); + .that.equals('cookie \'JSESSIONID\' required'); }); }); - it('Should return 200 WHEN one of multiple security rules is met GIVEN a request with apiKey and bearer token', () => { + it("Should return 200 WHEN one of multiple security rules is met GIVEN a request with apiKey and bearer token", () => { return request(app) .get(`${basePath}/multi_auth`) .set({ - Authorization: 'Bearer rawww', - 'X-API-Key': 'hello world', + "Authorization": "Bearer rawww", + "X-API-Key": "hello world" }) - .expect(200); - }); + .expect(200) + }) - it('Should return 200 WHEN one of multiple security rules is met GIVEN a request with cookie and basic auth', () => { + it("Should return 200 WHEN one of multiple security rules is met GIVEN a request with cookie and basic auth", () => { return request(app) .get(`${basePath}/multi_auth`) .set({ - Authorization: 'Basic ZGVtbzpwQDU1dzByZA==', - Cookie: 'JSESSIONID=dwdwdwdwd', + "Authorization": "Basic ZGVtbzpwQDU1dzByZA==", + "Cookie": "JSESSIONID=dwdwdwdwd" }) - .expect(200); - }); + .expect(200) + }) - it('Should return 401 WHEN none of multiple security rules is met GIVEN a request with only cookie auth', () => { + it("Should return 401 WHEN none of multiple security rules is met GIVEN a request with only cookie auth", () => { return request(app) .get(`${basePath}/multi_auth`) .set({ - Cookie: 'JSESSIONID=dwdwdwdwd', + "Cookie": "JSESSIONID=dwdwdwdwd" }) - .expect(401); - }); + .expect(401) + }) }); diff --git a/test/security.disabled.spec.ts b/test/security.disabled.spec.ts index 9e0c75b6..610c0bf3 100644 --- a/test/security.disabled.spec.ts +++ b/test/security.disabled.spec.ts @@ -29,13 +29,19 @@ describe('security.disabled', () => { }); it('should return 200 if no security', async () => - request(app).get(`${basePath}/no_security`).expect(200)); + request(app) + .get(`${basePath}/no_security`) + .expect(200)); it('should skip validation, even if auth header is missing for basic auth', async () => { - return request(app).get(`${basePath}/basic`).expect(200); + return request(app) + .get(`${basePath}/basic`) + .expect(200); }); it('should skip security validation, even if auth header is missing for bearer auth', async () => { - return request(app).get(`${basePath}/bearer`).expect(200); + return request(app) + .get(`${basePath}/bearer`) + .expect(200); }); }); diff --git a/test/security.top.level.spec.ts b/test/security.top.level.spec.ts index e5113494..8f8641a8 100644 --- a/test/security.top.level.spec.ts +++ b/test/security.top.level.spec.ts @@ -38,7 +38,7 @@ describe('security.top.level', () => { request(app) .get(`${basePath}/api_key`) .expect(401) - .then((r) => { + .then(r => { const body = r.body; expect(body.errors).to.be.an('array'); expect(body.errors).to.have.length(1); @@ -56,7 +56,7 @@ describe('security.top.level', () => { .get(`${basePath}/api_key_undefined_path`) .set('X-API-Key', 'test') .expect(404) - .then((r) => { + .then(r => { const body = r.body; expect(body.errors).to.be.an('array'); expect(body.errors).to.have.length(1); @@ -68,7 +68,7 @@ describe('security.top.level', () => { .post(`${basePath}/api_key`) .set('X-API-Key', 'test') .expect(405) - .then((r) => { + .then(r => { const body = r.body; expect(body.errors).to.be.an('array'); expect(body.errors).to.have.length(1); @@ -98,13 +98,15 @@ describe('security.top.level', () => { .expect(200), ); it('should return 200 if apikey or anonymous', async () => - request(app).get(`${basePath}/api_key_or_anonymous`).expect(200)); + request(app) + .get(`${basePath}/api_key_or_anonymous`) + .expect(200)); it('should override api key with bearer and return 401 if bearer is missing', async () => request(app) .get(`${basePath}/bearer`) .expect(401) - .then((r) => { + .then(r => { const body = r.body; expect(body.errors).to.be.an('array'); expect(body.errors).to.have.length(1); @@ -120,8 +122,12 @@ describe('security.top.level', () => { .expect(200)); it('should override api key with anonymous', async () => - request(app).get(`${basePath}/anonymous_2`).expect(200)); + request(app) + .get(`${basePath}/anonymous_2`) + .expect(200)); it('should override api key with anonymous', async () => - request(app).get(`${basePath}/anonymous`).expect(200)); + request(app) + .get(`${basePath}/anonymous`) + .expect(200)); }); diff --git a/test/serdes.spec.ts b/test/serdes.spec.ts index e3504b4e..25774403 100644 --- a/test/serdes.spec.ts +++ b/test/serdes.spec.ts @@ -10,18 +10,19 @@ const apiSpecPath = path.join('test', 'resources', 'serdes.yaml'); class ObjectID { id: string; - constructor(id: string = '5fdefd13a6640bb5fb5fa925') { + constructor(id: string = "5fdefd13a6640bb5fb5fa925") { this.id = id; } toString() { return this.id; } + } class BadDate extends Date { public toISOString(): string { - return 'oh no a bad iso date'; + return "oh no a bad iso date"; } } @@ -29,9 +30,9 @@ function toSummary(title, value) { return { [title]: { value: value?.toISOString?.() || value?.toString(), - typeof: typeof value, - }, - }; + typeof: typeof value + } + } } describe('serdes', () => { @@ -43,16 +44,16 @@ describe('serdes', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true, + coerceTypes: true }, validateResponses: { - coerceTypes: true, + coerceTypes: true }, serDes: [ date, dateTime, { - format: 'mongo-objectid', + format: "mongo-objectid", deserialize: (s) => new ObjectID(s), serialize: (o) => o.toString(), }, @@ -63,54 +64,36 @@ describe('serdes', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'object') { - throw new Error('Should be deserialized to ObjectId object'); + throw new Error("Should be deserialized to ObjectId object"); } - let date = new Date('2020-12-20T07:28:19.213Z'); + let date = new Date("2020-12-20T07:28:19.213Z"); res.json({ id: req.params.id, creationDateTime: date, creationDate: date, shortOrLong: 'a', summary: { - ...toSummary( - 'req.query.date-time-from-inline', - req.query['date-time-from-inline'], - ), - ...toSummary( - 'req.query.date-time-from-schema', - req.query['date-time-from-schema'], - ), + ...toSummary('req.query.date-time-from-inline', req.query['date-time-from-inline']), + ...toSummary('req.query.date-time-from-schema', req.query['date-time-from-schema']), }, }); }); app.post([`${app.basePath}/users`], (req, res) => { if (typeof req.body.id !== 'object') { - throw new Error('Should be deserialized to ObjectId object'); + throw new Error("Should be deserialized to ObjectId object"); } - if ( - typeof req.body.creationDate !== 'object' || - !(req.body.creationDate instanceof Date) - ) { - throw new Error('Should be deserialized to Date object'); + if (typeof req.body.creationDate !== 'object' || !(req.body.creationDate instanceof Date)) { + throw new Error("Should be deserialized to Date object"); } - if ( - typeof req.body.creationDateTime !== 'object' || - !(req.body.creationDateTime instanceof Date) - ) { - throw new Error('Should be deserialized to Date object'); + if (typeof req.body.creationDateTime !== 'object' || !(req.body.creationDateTime instanceof Date)) { + throw new Error("Should be deserialized to Date object"); } - if ( - typeof req.body.creationDateTimeInline !== 'object' || - !(req.body.creationDateTimeInline instanceof Date) - ) { - throw new Error('Should be deserialized to Date object'); + if (typeof req.body.creationDateTimeInline !== 'object' || !(req.body.creationDateTimeInline instanceof Date)) { + throw new Error("Should be deserialized to Date object"); } res.json({ ...req.body, - summary: Object.entries(req.body).reduce( - (acc, [k, v]) => Object.assign(acc, toSummary(k, v)), - {}, - ), + summary: Object.entries(req.body).reduce((acc, [k, v]) => Object.assign(acc, toSummary(k, v)), {}) }); }); app.use((err, req, res, next) => { @@ -122,7 +105,7 @@ describe('serdes', () => { }, false, ); - return app; + return app }); after(() => { @@ -134,33 +117,21 @@ describe('serdes', () => { .get(`${app.basePath}/users/1234`) .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/params/id must match pattern "^[0-9a-fA-F]{24}$"', - ); + expect(r.body.message).to.equal('request/params/id must match pattern "^[0-9a-fA-F]{24}$"'); })); it('should control GOOD id format and get a response in expected format', async () => request(app) - .get( - `${app.basePath}/users/5fdefd13a6640bb5fb5fa925?date-time-from-inline=2019-11-20T01%3A11%3A54.930Z&date-time-from-schema=2020-11-20T01%3A11%3A54.930Z`, - ) + .get(`${app.basePath}/users/5fdefd13a6640bb5fb5fa925?date-time-from-inline=2019-11-20T01%3A11%3A54.930Z&date-time-from-schema=2020-11-20T01%3A11%3A54.930Z`) .expect(200) .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); - expect( - r.body.summary['req.query.date-time-from-schema'].value, - ).to.equal('2020-11-20T01:11:54.930Z'); - expect( - r.body.summary['req.query.date-time-from-schema'].typeof, - ).to.equal('object'); - expect( - r.body.summary['req.query.date-time-from-inline'].value, - ).to.equal('2019-11-20T01:11:54.930Z'); - expect( - r.body.summary['req.query.date-time-from-inline'].typeof, - ).to.equal('object'); + expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); + expect(r.body.summary['req.query.date-time-from-schema'].value).to.equal("2020-11-20T01:11:54.930Z"); + expect(r.body.summary['req.query.date-time-from-schema'].typeof).to.equal("object"); + expect(r.body.summary['req.query.date-time-from-inline'].value).to.equal("2019-11-20T01:11:54.930Z"); + expect(r.body.summary['req.query.date-time-from-inline'].typeof).to.equal("object"); })); it('should POST also works with deserialize on request then serialize en response', async () => @@ -178,21 +149,13 @@ describe('serdes', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); - expect(r.body.summary['creationDate'].value).to.equal( - '2020-12-20T00:00:00.000Z', - ); + expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); + expect(r.body.summary['creationDate'].value).to.equal('2020-12-20T00:00:00.000Z'); expect(r.body.summary['creationDate'].typeof).to.equal('object'); - expect(r.body.summary['creationDateTime'].value).to.equal( - '2020-12-20T07:28:19.213Z', - ); + expect(r.body.summary['creationDateTime'].value).to.equal('2020-12-20T07:28:19.213Z'); expect(r.body.summary['creationDateTime'].typeof).to.equal('object'); - expect(r.body.summary['creationDateTimeInline'].value).to.equal( - '2019-11-21T07:24:19.213Z', - ); - expect(r.body.summary['creationDateTimeInline'].typeof).to.equal( - 'object', - ); + expect(r.body.summary['creationDateTimeInline'].value).to.equal('2019-11-21T07:24:19.213Z'); + expect(r.body.summary['creationDateTimeInline'].typeof).to.equal('object'); })); it('should POST throw error on invalid schema ObjectId', async () => @@ -207,9 +170,7 @@ describe('serdes', () => { .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/id must match pattern "^[0-9a-fA-F]{24}$"', - ); + expect(r.body.message).to.equal('request/body/id must match pattern "^[0-9a-fA-F]{24}$"'); })); it('should POST throw error on invalid schema Date', async () => @@ -218,14 +179,12 @@ describe('serdes', () => { .send({ id: '5fdefd13a6640bb5fb5fa925', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-1f-20', + creationDate: '2020-1f-20' }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/creationDate must match format "date"', - ); + expect(r.body.message).to.equal('request/body/creationDate must match format "date"'); })); it('should enforce anyOf validations', async () => @@ -250,6 +209,8 @@ describe('serdes', () => { })); }); + + describe('serdes serialize response components only', () => { let app = null; @@ -259,16 +220,16 @@ describe('serdes serialize response components only', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true, + coerceTypes: true }, validateResponses: { - coerceTypes: true, + coerceTypes: true }, serDes: [ date.serializer, dateTime.serializer, { - format: 'mongo-objectid', + format: "mongo-objectid", serialize: (o) => o.toString(), }, ], @@ -278,9 +239,9 @@ describe('serdes serialize response components only', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'string') { - throw new Error('Should be not be deserialized to ObjectId object'); + throw new Error("Should be not be deserialized to ObjectId object"); } - let date = new Date('2020-12-20T07:28:19.213Z'); + let date = new Date("2020-12-20T07:28:19.213Z"); let result = { id: new ObjectID(req.params.id), creationDateTime: date, @@ -289,22 +250,24 @@ describe('serdes serialize response components only', () => { }; if (req.query.baddateresponse === 'functionNotExists') { result.creationDate = new ObjectID(); - } else if (req.query.baddateresponse === 'functionBadFormat') { + } + else if (req.query.baddateresponse === 'functionBadFormat') { result.creationDate = new BadDate(); - } else { + } + else { result.creationDate = date; } res.json(result); }); app.post([`${app.basePath}/users`], (req, res) => { if (typeof req.body.id !== 'string') { - throw new Error('Should NOT be deserialized to ObjectId object'); + throw new Error("Should NOT be deserialized to ObjectId object"); } if (typeof req.body.creationDate !== 'string') { - throw new Error('Should NTO be deserialized to Date object'); + throw new Error("Should NTO be deserialized to Date object"); } if (typeof req.body.creationDateTime !== 'string') { - throw new Error('Should NOT be deserialized to Date object'); + throw new Error("Should NOT be deserialized to Date object"); } req.body.id = new ObjectID(req.body.id); req.body.creationDateTime = new Date(req.body.creationDateTime); @@ -320,7 +283,7 @@ describe('serdes serialize response components only', () => { }, false, ); - return app; + return app }); after(() => { @@ -332,9 +295,7 @@ describe('serdes serialize response components only', () => { .get(`${app.basePath}/users/1234`) .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/params/id must match pattern "^[0-9a-fA-F]{24}$"', - ); + expect(r.body.message).to.equal('request/params/id must match pattern "^[0-9a-fA-F]{24}$"'); })); it('should control GOOD id format and get a response in expected format', async () => @@ -344,7 +305,7 @@ describe('serdes serialize response components only', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); + expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); })); it('should POST also works with deserialize on request then serialize en response', async () => @@ -353,14 +314,14 @@ describe('serdes serialize response components only', () => { .send({ id: '5fdefd13a6640bb5fb5fa925', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-12-20', + creationDate: '2020-12-20' }) .set('Content-Type', 'application/json') .expect(200) .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); + expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); })); it('should POST throw error on invalid schema ObjectId', async () => @@ -369,14 +330,12 @@ describe('serdes serialize response components only', () => { .send({ id: '5fdefd13a6640bb5fb5fa', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-12-20', + creationDate: '2020-12-20' }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/id must match pattern "^[0-9a-fA-F]{24}$"', - ); + expect(r.body.message).to.equal('request/body/id must match pattern "^[0-9a-fA-F]{24}$"'); })); it('should POST throw error on invalid schema Date', async () => @@ -385,14 +344,12 @@ describe('serdes serialize response components only', () => { .send({ id: '5fdefd13a6640bb5fb5fa925', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-1f-20', + creationDate: '2020-1f-20' }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/creationDate must match format "date"', - ); + expect(r.body.message).to.equal('request/body/creationDate must match format "date"'); })); it('should throw error 500 on invalid object type instead of Date expected', async () => @@ -440,6 +397,7 @@ describe('serdes serialize response components only', () => { })); */ + }); describe('serdes with array type string-list', () => { @@ -451,22 +409,22 @@ describe('serdes with array type string-list', () => { { apiSpec: apiSpecPath, validateRequests: { - coerceTypes: true, + coerceTypes: true }, validateResponses: { - coerceTypes: true, + coerceTypes: true }, serDes: [ date, dateTime, { - format: 'mongo-objectid', + format: "mongo-objectid", deserialize: (s) => new ObjectID(s), serialize: (o) => o.toString(), }, { format: 'string-list', - deserialize: (s): string[] => s.split(',').map((s) => s.trim()), + deserialize: (s): string[] => s.split(',').map(s => s.trim()), serialize: (o): string => (o as string[]).join(','), }, ], @@ -475,34 +433,28 @@ describe('serdes with array type string-list', () => { (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { if (typeof req.params.id !== 'object') { - throw new Error('Should be deserialized to ObjectId object'); + throw new Error("Should be deserialized to ObjectId object"); } - let date = new Date('2020-12-20T07:28:19.213Z'); + let date = new Date("2020-12-20T07:28:19.213Z"); res.json({ id: req.params.id, tags: ['aa', 'bb', 'cc'], creationDateTime: date, - creationDate: date, + creationDate: date }); }); app.post([`${app.basePath}/users`], (req, res) => { if (typeof req.body.id !== 'object') { - throw new Error('Should be deserialized to ObjectId object'); + throw new Error("Should be deserialized to ObjectId object"); } if (!Array.isArray(req.body.tags)) { - throw new Error('Should be deserialized to an Array object'); + throw new Error("Should be deserialized to an Array object"); } - if ( - typeof req.body.creationDate !== 'object' || - !(req.body.creationDate instanceof Date) - ) { - throw new Error('Should be deserialized to Date object'); + if (typeof req.body.creationDate !== 'object' || !(req.body.creationDate instanceof Date)) { + throw new Error("Should be deserialized to Date object"); } - if ( - typeof req.body.creationDateTime !== 'object' || - !(req.body.creationDateTime instanceof Date) - ) { - throw new Error('Should be deserialized to Date object'); + if (typeof req.body.creationDateTime !== 'object' || !(req.body.creationDateTime instanceof Date)) { + throw new Error("Should be deserialized to Date object"); } res.json(req.body); }); @@ -515,7 +467,7 @@ describe('serdes with array type string-list', () => { }, false, ); - return app; + return app }); after(() => { @@ -527,9 +479,7 @@ describe('serdes with array type string-list', () => { .get(`${app.basePath}/users/1234`) .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/params/id must match pattern "^[0-9a-fA-F]{24}$"', - ); + expect(r.body.message).to.equal('request/params/id must match pattern "^[0-9a-fA-F]{24}$"'); })); it('should control GOOD id format and get a response in expected format', async () => { @@ -539,11 +489,12 @@ describe('serdes with array type string-list', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); + expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); expect(r.body.tags).to.equal('aa,bb,cc'); - }); + }) }); + it('should POST also works with deserialize on request then serialize en response', async () => request(app) .post(`${app.basePath}/users`) @@ -559,7 +510,7 @@ describe('serdes with array type string-list', () => { .then((r) => { expect(r.body.id).to.equal('5fdefd13a6640bb5fb5fa925'); expect(r.body.creationDate).to.equal('2020-12-20'); - expect(r.body.creationDateTime).to.equal('2020-12-20T07:28:19.213Z'); + expect(r.body.creationDateTime).to.equal("2020-12-20T07:28:19.213Z"); expect(r.body.tags).to.equal('aa,bb,cc'); })); @@ -570,14 +521,12 @@ describe('serdes with array type string-list', () => { id: '5fdefd13a6640bb5fb5fa', tags: 'aa,bb,cc', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-12-20', + creationDate: '2020-12-20' }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/id must match pattern "^[0-9a-fA-F]{24}$"', - ); + expect(r.body.message).to.equal('request/body/id must match pattern "^[0-9a-fA-F]{24}$"'); })); it('should POST throw error on invalid schema Date', async () => @@ -587,14 +536,12 @@ describe('serdes with array type string-list', () => { id: '5fdefd13a6640bb5fb5fa925', tags: 'aa,bb,cc', creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-1f-20', + creationDate: '2020-1f-20' }) .set('Content-Type', 'application/json') .expect(400) .then((r) => { - expect(r.body.message).to.equal( - 'request/body/creationDate must match format "date"', - ); + expect(r.body.message).to.equal('request/body/creationDate must match format "date"'); })); it('should POST throw error for deserialize on request of non-string format', async () => @@ -604,7 +551,7 @@ describe('serdes with array type string-list', () => { id: '5fdefd13a6640bb5fb5fa925', tags: ['aa', 'bb', 'cc'], creationDateTime: '2020-12-20T07:28:19.213Z', - creationDate: '2020-12-20', + creationDate: '2020-12-20' }) .set('Content-Type', 'application/json') .expect(400) @@ -633,3 +580,5 @@ describe('serdes with array type string-list', () => { ); })); }); + + diff --git a/test/servers.spec.ts b/test/servers.spec.ts index f525f28c..ed229c29 100644 --- a/test/servers.spec.ts +++ b/test/servers.spec.ts @@ -14,15 +14,9 @@ describe(packageJson.name, () => { }, 3005, (app) => { - app.get(`/api/v1/petstore/ping`, (req, res) => - res.json({ ...req.body }), - ); - app.get(`/api/v2/storeofpets/ping`, (req, res) => - res.json({ ...req.body }), - ); - app.get(`/api/v3/petstore/ping`, (req, res) => - res.json({ ...req.body }), - ); + app.get(`/api/v1/petstore/ping`, (req, res) => res.json({ ...req.body })); + app.get(`/api/v2/storeofpets/ping`, (req, res) => res.json({ ...req.body })); + app.get(`/api/v3/petstore/ping`, (req, res) => res.json({ ...req.body })); }, true, ); @@ -37,48 +31,43 @@ describe(packageJson.name, () => { request(app).get('/api/v2/storeofpets/ping').send({}).expect(400)); it('should skip validation of api path with invalid enum value v3, and valid value petstore', async () => - // the validator should not validate routes that do note match one declare in the opeanpi apec - // in this case, 'v3' is not a valid value for api - // TODO throw an error instead of ignoring it + // the validator should not validate routes that do note match one declare in the opeanpi apec + // in this case, 'v3' is not a valid value for api + // TODO throw an error instead of ignoring it request(app).get('/api/v3/petstore/ping').send({}).expect(200)); }); describe(packageJson.name, () => { - let app = null; - - before(async () => { - const apiSpec = path.join('test', 'resources', 'servers.2.yaml'); - app = await createApp( - { - apiSpec, - }, - 3005, - (app) => { - app.get(`/api/v1:petstore/ping`, (req, res) => - res.json({ ...req.body }), - ); - app.get(`/api/v2:storeofpets/ping`, (req, res) => - res.json({ ...req.body }), - ); - app.get(`/api/v3:petstore/ping`, (req, res) => - res.json({ ...req.body }), - ); - }, - true, - ); + let app = null; + + before(async () => { + const apiSpec = path.join('test', 'resources', 'servers.2.yaml'); + app = await createApp( + { + apiSpec, + }, + 3005, + (app) => { + app.get(`/api/v1:petstore/ping`, (req, res) => res.json({ ...req.body })); + app.get(`/api/v2:storeofpets/ping`, (req, res) => res.json({ ...req.body })); + app.get(`/api/v3:petstore/ping`, (req, res) => res.json({ ...req.body })); + }, + true, + ); + }); + + after(() => app.server.close()); + + it('should validate server path with version variables, v2 and petstore', async () => + request(app).get('/api/v1:petstore/ping').query({}).expect(400)); + + it('should validate server path with version variables, v2 and storeofpets', async () => + request(app).get('/api/v2:storeofpets/ping').send({}).expect(400)); + + it('should skip validation of api path with invalid variable value, v2, and valid variable petstore', async () => + // the validator should not validate routes that do note match one declare in the opeanpi apec + // in this case, 'v3' is not a valid value for api + // TODO throw an error instead of ignoring it + request(app).get('/api/v3:petstore/ping').send({}).expect(200)); }); - - after(() => app.server.close()); - - it('should validate server path with version variables, v2 and petstore', async () => - request(app).get('/api/v1:petstore/ping').query({}).expect(400)); - - it('should validate server path with version variables, v2 and storeofpets', async () => - request(app).get('/api/v2:storeofpets/ping').send({}).expect(400)); - - it('should skip validation of api path with invalid variable value, v2, and valid variable petstore', async () => - // the validator should not validate routes that do note match one declare in the opeanpi apec - // in this case, 'v3' is not a valid value for api - // TODO throw an error instead of ignoring it - request(app).get('/api/v3:petstore/ping').send({}).expect(200)); -}); + \ No newline at end of file