Imagine you’ve built something amazing — a backend, filled with valuable data (like the list of classic poets, maybe?). You’ve stored it somewhere on a server, and now you want the world to access it.
You’ve finished step one: building and hosting your backend.
But here comes step two:
How do people know how to talk to your API?
How do they know what endpoints exist, what data to send, or what they’ll receive back?
That’s where Swagger comes in.
What is Swagger?
Swagger is your API’s guidebook. It’s actually a set of tools built around a format called OpenAPI — a standard way to describe RESTful APIs(explained below).
With Swagger, you get:
A visual, interactive documentation of your API (you’ve seen those websites where you can test the endpoints live? That’s Swagger UI)
A way to describe all the endpoints, input parameters, and response shapes.
Tools to test and simulate API calls.
Basically, Swagger helps you answer:
“How do I interact with this API?”
...without guessing or asking the backend team every five minutes.
What are REST APIs?
APIs (Application Programming Interfaces) let two software pieces talk to each other.
REST APIs (REpresentational State Transfer) are the most common kind. They work using HTTP verbs like:
GET – retrieve data
POST – send new data
PUT – update existing data
DELETE – remove data
So when Swagger documents a REST API, it's just showing:
Here's how to GET /poets,
Here's how to POST /users,
And here’s what the response looks like.
What Is Orval?
Okay, now imagine you're building the frontend app — like a React Native app with Expo.
You read the Swagger doc and think, “Cool, now I know how to call the API.”
But wouldn't it be better if someone just wrote the code for calling the API for you?
That someone is Orval.
Orval:
Takes the Swagger/OpenAPI file
Understands all the endpoints
Generates perfect TypeScript code
Even gives you ready-made React Query hooks like useGetPoets()
So instead of writing boilerplate fetch or Axios calls, you get clean, type-safe, reusable functions.
Bonus: Zod
When using Orval, you can also enable Zod, a TypeScript-first schema validation library.
Zod acts like a gatekeeper at your app’s entrance:
It checks incoming data
If it doesn’t match your expected shape, it blocks it
Prevents bugs and crashes from unexpected responses.
Ps: Why use Zod?
Because TypeScript is only a compile-time tool.
It helps catch errors while you're writing code
But it doesn’t run in your final app
It can’t protect you at runtime
So if you call an API and the server sends broken or unexpected data, TypeScript won’t help.