Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding example field for date format property #55

Open
glodieu opened this issue Dec 6, 2016 · 0 comments
Open

Question regarding example field for date format property #55

glodieu opened this issue Dec 6, 2016 · 0 comments

Comments

@glodieu
Copy link

glodieu commented Dec 6, 2016

Hi, I've this Swagger file. Please take a look to the dateOfBirth example fields, both are '1978-06-21'.
But after executing swagger-parser, output is an object and I don't know how obtain original value.
Could you please help me with this?
Thanks.

Swagger file:

info:
  version: 0.0.1
  title: Simple API

paths:
  /persons:
    get:
      responses:
        '200':
          description: A list of Person
          schema:
            $ref: '#/definitions/Persons'
definitions:
  Person:
    title: Human
    properties:
      dateOfBirth:
        type: string
        format: date
        example: 1978-06-21
      lastTimeOnline:
        type: string
        format: date-time
        readOnly: true
        example: 2016-06-10T12:36:58.014Z
  Persons:
    properties:
      items:
        type: array
        items:
          $ref: '#/definitions/Person'
        example:
          - dateOfBirth: 1970-01-28
            lastTimeOnline: 2016-04-10T14:36:58.014Z

Parser output:

    "definitions": {
        "Person": {
            "properties": {
                "dateOfBirth": {
                    "example": "1978-06-21T00:00:00.000Z",
                    "format": "date",
                    "type": "string"
                },
                "lastTimeOnline": {
                    "example": "2016-06-10T12:36:58.014Z",
                    "format": "date-time",
                    "readOnly": true,
                    "type": "string"
                }
            },
            "title": "Human"
        },
        "Persons": {
            "properties": {
                "items": {
                    "example": [
                        {
                            "dateOfBirth": "1970-01-28T00:00:00.000Z",
                            "lastTimeOnline": "2016-04-10T14:36:58.014Z"
                        }
                    ],
                    "items": {
                        "$ref": "#/definitions/Person"
                    },
                    "type": "array"
                }
            }
        }
    },
    "info": {
        "title": "Simple API",
        "version": "0.0.1"
    },
    "paths": {
        "/persons": {
            "get": {
                "responses": {
                    "200": {
                        "description": "A list of Person",
                        "schema": {
                            "$ref": "#/definitions/Persons"
                        }
                    }
                }
            }
        }
    },
    "swagger": "2.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant