Defining your API
Fern Definition
Defining your API
Fern Definition
A Fern Definition is a set of YAML files that describe your API.
Each Fern Definition file may define:
- Custom types. Use custom types to build your data model.
- Services. A service is a set of related REST endpoints.
- Errors. An error represents a failed (non-200) response from an endpoint.
An example of a Fern Definition
imdb.yml
service:
auth: false
base-path: /movies
endpoints:
createMovie:
docs: Add a movie to the database
method: POST
path: /create-movie
request: CreateMovieRequest
response: MovieId
getMovie:
method: GET
path: /{movieId}
path-parameters:
movieId: MovieId
response: Movie
errors:
- NotFoundError
- UnauthorizedError
types:
Movie:
properties:
title: string
rating:
type: double
docs: The rating scale from one to five stars
id:
type: MovieId
docs: The unique identifier for a movie
CreateMovieRequest:
properties:
title: string
rating: double
errors:
NotFoundError:
http:
statusCode: 404
type:
properties:
id: MovieId
UnauthorizedError:
http:
statusCode: 401