openapi-backend
Advanced tools
Comparing version
{ | ||
"name": "openapi-backend", | ||
"description": "Build, Validate, Route, Authenticate and Mock using OpenAPI definitions. Framework-agnostic", | ||
"version": "5.10.0", | ||
"version": "5.10.1", | ||
"author": "Viljami Kuosmanen <viljami@viljami.io>", | ||
@@ -25,6 +25,6 @@ "funding": "https://github.com/sponsors/anttiviljami", | ||
"type": "git", | ||
"url": "git+https://github.com/anttiviljami/openapi-backend.git" | ||
"url": "git+https://github.com/openapistack/openapi-backend.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/anttiviljami/openapi-backend/issues" | ||
"url": "https://github.com/openapistack/openapi-backend/issues" | ||
}, | ||
@@ -31,0 +31,0 @@ "main": "index.js", |
<h1 align="center"><img alt="openapi-backend" src="./header.png" style="max-width:50rem"></h1> | ||
[](https://github.com/anttiviljami/openapi-backend/actions?query=workflow%3ACI) | ||
[](https://github.com/openapistack/openapi-backend/actions?query=workflow%3ACI) | ||
[](https://www.npmjs.com/package/openapi-backend) | ||
[](https://www.npmjs.com/package/openapi-backend) | ||
[](https://github.com/anttiviljami/openapi-backend/blob/master/LICENSE) | ||
[](https://github.com/openapistack/openapi-backend/blob/main/LICENSE) | ||
[](https://buymeacoff.ee/anttiviljami) | ||
@@ -36,3 +36,3 @@ | ||
Full [example projects](https://github.com/anttiviljami/openapi-backend/tree/master/examples) included in the repo | ||
Full [example projects](https://github.com/openapistack/openapi-backend/tree/main/examples) included in the repo | ||
@@ -72,5 +72,5 @@ ``` | ||
[See full Express example](https://github.com/anttiviljami/openapi-backend/tree/master/examples/express) | ||
[See full Express example](https://github.com/openapistack/openapi-backend/tree/main/examples/express) | ||
[See full Express TypeScript example](https://github.com/anttiviljami/openapi-backend/tree/master/examples/express-typescript) | ||
[See full Express TypeScript example](https://github.com/openapistack/openapi-backend/tree/main/examples/express-typescript) | ||
@@ -95,8 +95,10 @@ ### AWS Serverless (Lambda) | ||
[See full AWS SAM example](https://github.com/anttiviljami/openapi-backend/tree/master/examples/aws-sam) | ||
[See full AWS SAM example](https://github.com/openapistack/openapi-backend/tree/main/examples/aws-sam) | ||
[See full AWS CDK example](https://github.com/anttiviljami/openapi-backend/tree/master/examples/aws-cdk) | ||
[See full AWS CDK example](https://github.com/openapistack/openapi-backend/tree/main/examples/aws-cdk) | ||
[See full Serverless Framework example](https://github.com/anttiviljami/openapi-backend/tree/master/examples/serverless-framework) | ||
[See full SST example](https://github.com/openapistack/openapi-backend/tree/main/examples/aws-sst) | ||
[See full Serverless Framework example](https://github.com/openapistack/openapi-backend/tree/main/examples/serverless-framework) | ||
### Azure Function | ||
@@ -119,3 +121,3 @@ | ||
[See full Azure Function example](https://github.com/anttiviljami/openapi-backend/tree/master/examples/azure-function) | ||
[See full Azure Function example](https://github.com/openapistack/openapi-backend/tree/main/examples/azure-function) | ||
@@ -146,3 +148,3 @@ ### Fastify | ||
[See full Fastify example](https://github.com/anttiviljami/openapi-backend/tree/master/examples/fastify) | ||
[See full Fastify example](https://github.com/openapistack/openapi-backend/tree/main/examples/fastify) | ||
@@ -174,3 +176,3 @@ ### Hapi | ||
[See full Hapi example](https://github.com/anttiviljami/openapi-backend/tree/master/examples/hapi-typescript) | ||
[See full Hapi example](https://github.com/openapistack/openapi-backend/tree/main/examples/hapi-typescript) | ||
@@ -196,9 +198,9 @@ | ||
[See full Koa example](https://github.com/anttiviljami/openapi-backend/tree/master/examples/koa) | ||
[See full Koa example](https://github.com/openapistack/openapi-backend/tree/main/examples/koa) | ||
## Registering Handlers for Operations | ||
Handlers are registered for [`operationIds`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#fixed-fields-8) | ||
found in the OpenAPI definitions. You can register handlers as shown above with [`new OpenAPIBackend()`](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#parameter-optshandlers) | ||
constructor opts, or using the [`register()`](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#registeroperationid-handler) | ||
Handlers are registered for [`operationIds`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#fixed-fields-8) | ||
found in the OpenAPI definitions. You can register handlers as shown above with [`new OpenAPIBackend()`](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#parameter-optshandlers) | ||
constructor opts, or using the [`register()`](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#registeroperationid-handler) | ||
method. | ||
@@ -219,3 +221,3 @@ | ||
Operation handlers are passed a special [Context object](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#context-object) | ||
Operation handlers are passed a special [Context object](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#context-object) | ||
as the first argument, which contains the parsed request, the | ||
@@ -227,3 +229,3 @@ matched API operation and input validation results. The other arguments in the example above are Express-specific | ||
The easiest way to enable request validation in your API is to register a [`validationFail`](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#validationfail-handler) | ||
The easiest way to enable request validation in your API is to register a [`validationFail`](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#validationfail-handler) | ||
handler. | ||
@@ -241,3 +243,3 @@ | ||
The context object `c` gets a `validation` property with the [validation result](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#validationresult-object). | ||
The context object `c` gets a `validation` property with the [validation result](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#validationresult-object). | ||
@@ -247,4 +249,4 @@ ## Response validation | ||
OpenAPIBackend doesn't automatically perform response validation for your handlers, but you can register a | ||
[`postResponseHandler`](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#postresponsehandler-handler) | ||
to add a response validation step using [`validateResponse`](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#validateresponseres-operation). | ||
[`postResponseHandler`](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#postresponsehandler-handler) | ||
to add a response validation step using [`validateResponse`](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#validateresponseres-operation). | ||
@@ -268,3 +270,3 @@ ```javascript | ||
It's also possible to validate the response headers using [`validateResponseHeaders`](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#validateresponseheadersheaders-operation-opts). | ||
It's also possible to validate the response headers using [`validateResponseHeaders`](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#validateresponseheadersheaders-operation-opts). | ||
@@ -317,5 +319,5 @@ ```javascript | ||
The authorization status and return values of each security handler can be | ||
accessed via the [Context Object](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#context-object) | ||
accessed via the [Context Object](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#context-object) | ||
You can also register an [`unauthorizedHandler`](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#unauthorizedhandler-handler) | ||
You can also register an [`unauthorizedHandler`](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#unauthorizedhandler-handler) | ||
to handle unauthorized requests. | ||
@@ -330,9 +332,9 @@ | ||
See examples: | ||
- [API Key auth (express)](https://github.com/anttiviljami/openapi-backend/tree/master/examples/express-apikey-auth) | ||
- [JWT auth (express)](https://github.com/anttiviljami/openapi-backend/tree/master/examples/express-jwt-auth) | ||
- [API Key auth (express)](https://github.com/openapistack/openapi-backend/tree/main/examples/express-apikey-auth) | ||
- [JWT auth (express)](https://github.com/openapistack/openapi-backend/tree/main/examples/express-jwt-auth) | ||
## Mocking API responses | ||
Mocking APIs just got really easy with OpenAPI Backend! Register a [`notImplemented`](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#notimplemented-handler) | ||
handler and use [`mockResponseForOperation()`](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md##mockresponseforoperationoperationid-opts) | ||
Mocking APIs just got really easy with OpenAPI Backend! Register a [`notImplemented`](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md#notimplemented-handler) | ||
handler and use [`mockResponseForOperation()`](https://github.com/openapistack/openapi-backend/blob/main/DOCS.md##mockresponseforoperationoperationid-opts) | ||
to generate mock responses for operations with no custom handlers specified yet: | ||
@@ -396,3 +398,3 @@ | ||
[See full Mock API example on Express](https://github.com/anttiviljami/openapi-backend/tree/master/examples/express-ts-mock) | ||
[See full Mock API example on Express](https://github.com/openapistack/openapi-backend/tree/main/examples/express-ts-mock) | ||
@@ -399,0 +401,0 @@ ## Contributing |
152942
0.03%390
0.52%