Skip to content

Example mock REST API (RAML, autogen: docs, mocks, api, TS definitions)

Notifications You must be signed in to change notification settings

ducin-public/example-service-contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contract-first

Contract-first design approach aims to make RESTful API development smooth, transparent and predictable. GIven a business task, developers of both backend and frontend systems (including mobile apps) discuss the features. No code is written at this step. They discuss what resources need to be available, what is their content, parameters, potential headers, content-types and all corner-cases, etc. Then the API design is written down (HTTP: urls, methods, content, content-type, statuses, headers, etc along with JSON Schema) developers of different parts can split and implement their part, according to the contract.

RAML

RESTful API Modelling Language - YAML-based DSL for declaring REST API shape, semantics, content, etc. Tooling around RAML lets you automate many repetitive and time-consuming tasks, such as mock generation, BE integration tests, docs generation and so on.

More info on RAML can be found at the docs and this tutorial.

Mock REST API

Based on json-server npm package and json-schema-faker npm package.

Usage

npm run contract-docs

Generates API contract as HTML/CSS files, output placed under docs/ directory. Use npm:http-server or any other WWW server.

npm run contract-typedef

Uses raml-to-typescript and json-schema-to-typescript to generate TypeScript definitions out of JSON Schema definitions.

npm run mock-generate

Reads JSON Schema files and generates mock database file, basing on it.

npm run mock-api

Uses json-server to run the mocked API (in-memory, SIGINT makes changes persistent in db file).

About

Example mock REST API (RAML, autogen: docs, mocks, api, TS definitions)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published