Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 2 - Validating Requests #1

Open
wants to merge 1 commit into
base: chapter-1-crud-api
Choose a base branch
from

Conversation

clairefro
Copy link
Collaborator

We need to make sure our API returns a 400 Bad Request error if a client makes a crazy request that doesn't match our schema, like:

POST /restaurants
with a Body of { "someCrazyProperty": "nonsense"}

We can enforce our OpenAPI schema on our fastify API using the plugin library fastify-openapi-glue

This library identifies each of our paths by their operationId in our schema.yaml, and converts them into fastify routes with the correct request methods. Better yet, the generated routes check each request to that route and make sure it fits our schema, or else it sends an error to the client!

API First makes life easy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant