From aa1515340d1a54cba835b0ca0f243b50d22a7711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cruz?= Date: Fri, 2 Aug 2024 19:01:51 +0100 Subject: [PATCH] Improve README --- README.md | 9 ++++++--- package.json | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1b3cbd1..a154efc 100644 --- a/README.md +++ b/README.md @@ -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.0 or 3.1 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 security schemes defined in your OpenAPI specification and operations, simplifying the implementation of authentication and authorization middleware. + ## Installation ```bash @@ -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) => { diff --git a/package.json b/package.json index f6c5b23..bee46bc 100644 --- a/package.json +++ b/package.json @@ -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.0 or 3.1 specification", "main": "./src/index.js", "types": "types/index.d.ts", "type": "module",