Schema Basics
The .fexapi schema file is where you define your mock API endpoints.
File Location
fexapi/schema.fexapiCreated automatically by fexapi init.
Syntax
A schema file contains two things: a port declaration and route definitions.
txt
port: 4000
GET /users:
id:uuid
name:name
email:email
age:number
GET /posts:
id:uuid
title:string
body:stringPort
Declares the server port. Optional — defaults to 4000.
txt
port: 4100Routes
Each route has three parts:
txt
METHOD /path:
fieldName:fieldType- METHOD — HTTP method (
GET,POST,PUT,DELETE) - /path — The endpoint path
- fields — One or more
name:typepairs
Supported methods are: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.
Single-Line Format
You can also write fields on a single line, comma-separated:
txt
GET /users: id:uuid,name:name,email:emailBoth formats are equivalent. Use fexapi format to convert single-line to multi-line.
Comments
Lines starting with # are comments:
txt
# Server configuration
port: 4000
# User endpoints
GET /users:
id:uuid
name:nameInline comments are also supported:
txt
port: 4000 # local dev port
GET /users:
id:uuid # primary key
name:nameValidation Rules
- Route definitions must be unique per
METHOD + /path. - Field names must use letters, numbers, or
_and cannot start with a number. - Field definitions must use strict
name:typeformat. - Field names must be unique within a route.
Multiple Routes
Define as many routes as you need:
txt
port: 4000
GET /users:
id:uuid
name:name
email:email
GET /products:
id:uuid
title:string
price:number
GET /orders:
id:uuid
total:number
date:date