Skip to content

Commit

Permalink
Improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Aug 2, 2024
1 parent 8694e07 commit 664b165
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# @uphold/fastify-openapi-router-plugin

This plugin provides an easy way to implement [Fastify](https://fastify.dev) routes from an OpenAPI 3.1 specification using `operationId` names.

[![Tests](https://github.com/uphold/fastify-openapi-router-plugin/actions/workflows/tests.yaml/badge.svg)](https://github.com/uphold/fastify-openapi-router-plugin/actions/workflows/tests.yaml)

A plugin for [Fastify](https://fastify.dev) to connect routes with a OpenAPI 3.x specification. It does so by:

- Providing a way to register routes using the `operationId` defined in your specification instead of having to manually call `fastify.route` with the correct URL, method, and schema.
- Handling securitySchemes and security keywords defined in your OpenAPI specification, simplifying the implementation of authentication and authorization middleware.

## Installation

```bash
Expand Down Expand Up @@ -204,7 +207,7 @@ fastify.oas.route({

### Error handler

If there was an error associated with `security` processing of a request, the plugin will throw an `UnauthorizedError`. It defaults to displaying a `401` status code with `{ code: 'unauthorized', 'message': 'Unauthorized' }` as the payload. You can override this behavior by registering a fastify error handler:
If there was an error associated with `security` processing of a request, the plugin will throw an `UnauthorizedError`. It defaults to displaying a `401` status code with `{ code: 'FST_OAS_UNAUTHORIZED', 'message': 'Unauthorized' }` as the payload. You can override this behavior by registering a fastify error handler:

```js
fastify.setErrorHandler((error, request, reply) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@uphold/fastify-openapi-router-plugin",
"version": "1.0.0",
"description": "A plugin for Fastify to connect routes with OpenAPI 3.0 specification",
"description": "A plugin for Fastify to connect routes with a OpenAPI 3.x specification",
"main": "./src/index.js",
"types": "types/index.d.ts",
"type": "module",
Expand Down

0 comments on commit 664b165

Please sign in to comment.