8000 Mocks are not properly generated since 0.1.12 · Issue #30 · yayoc/swagger-to-mock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Mocks are not properly generated since 0.1.12 #30
Open
@ben8p

Description

@ben8p

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0