swagger-server
swagger-server copied to clipboard
How to start with initialized data?
Is it possible to start swagger server with initialized mock data? I tried using examples property from responses in swagger but it didnt work.
/empresas:
get:
description: some description
parameters:
- $ref: "#/parameters/empresa"
responses:
'200':
schema:
title: ArrayOfEmpresa
type: array
items:
$ref: "#/definitions/empresa"
examples:
application/json:
- nome: Teste 1
id: 1
- nome: Teste 2
id: 2
I'm not sure you can add mock data to the yaml file.
However, I've been testing this project today and noticed that on sample 3 he demonstrates a way to initialize mock data. The data is loaded from @bigstickcarpet/mock-data - which is a directory within node_modules. See line 5 of employess.js
When loadMockData is executed during initialization it saves the employees in the mock data store.
You can follow a similar pattern to add initial data.