1. Defining your API
  2. Fern Definition

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