Mocks are not properly generated since 0.1.12
Opened this issue · 0 comments
ben8p commented
Description
When generating the mock, the JSON output is missing many fields.
This problem started with 0.1.12
.
It seems some references are not properly followed by the parser.
Reproduction
- Run
npm add swagger-to-mock@0.1.10
- Run
./node_modules/.bin/swagger-to-mock -d ./ ./test.yaml
- Output is
{
"items": [
{
"name": "",
"selected": {
"foo": {
"displayName": ""
},
"settings": {
"dayValue": 0
}
}
}
],
"responseMetadata": {
"apiVersion": ""
}
}
- Run
npm add swagger-to-mock@0.1.12
- Run
./node_modules/.bin/swagger-to-mock -d ./ ./test.yaml
- Output is
{
"items": [
{
"id": ""
}
],
"responseMetadata": {
"apiVersion": ""
}
}
Template used
openapi: 3.0.0
info:
description: This is a draft
version: draft-1.0.0
title: draft
paths:
/template:
get:
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/TemplateListEndpointResponse"
components:
schemas:
TemplateBase:
required:
- name
- selected
properties:
name:
type: string
selected:
$ref: "#/components/schemas/SelectedBase"
Template:
type: object
required:
- id
allOf:
- $ref: "#/components/schemas/TemplateBase"
properties:
id:
type: string
format: uuid
ResponseMetaData:
required:
- apiVersion
properties:
apiVersion:
type: string
TemplateListEndpointResponse:
type: object
properties:
items:
type: array
items:
$ref: "#/components/schemas/Template"
responseMetadata:
$ref: "#/components/schemas/ResponseMetaData"
SelectedBase:
required:
- foo
properties:
foo:
$ref: "#/components/schemas/Foo"
settings:
properties:
dayValue:
type: integer
minimum: 1
maximum: 31
Foo:
required:
- displayName
properties:
displayName :
type: string