codeasashu / react-openapi-designer

A React based UI toolkit to develop openapi schema

Home Page:https://codeasashu.github.io/react-openapi-designer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to add example

codeasashu opened this issue · comments

Given the following openapi yaml file:

openapi: 3.0.0
info:
  title: Campaign (WABA)
  version: '1.0'
paths:
  /campaigns:
    get:
      summary: List Campaigns
      tags: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties: {}
      operationId: get-campaigns
      parameters:
        - schema:
            type: string
          in: header
          name: X-waba-phonenumber-id
          description: Phone number id of WABA account to list campaigns
    post:
      summary: Create campaign
      operationId: post-campaigns
      responses:
        '200':
          description: OK
      parameters:
        - schema:
            type: string
          in: header
          name: X-waba-phonenumber-id
          description: Phone number id of WABA account to list campaigns
      description: Create a campaign for a WABA phone number
      requestBody:
        content:
          application/json:
            schema:
              title: ''
              type: object
              properties:
                name:
                  type: string
                  description: Name of campaign
                  maxLength: 50
                  minLength: 1
                  pattern: ^[\w\d\-_ ]+
              required:
                - name
  /jobs:
    get:
      summary: List jobs (campaign)
      tags: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                title: ''
                type: object
                properties:
                  status:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  data:
                    title: ''
                    type: object
                    required:
                      - count
                      - next
                      - previous
                      - results
                    properties:
                      count:
                        type: integer
                      next:
                        type: string
                        nullable: true
                        format: uri
                      previous:
                        type: string
                        nullable: true
                        format: uri
                      results:
                        title: ''
                        type: array
                        items:
                          $ref: '#/components/schemas/Campaign Job'
                required:
                  - status
                  - code
                  - message
                  - data
      operationId: get-jobs
      parameters:
        - schema:
            type: string
          in: header
          name: X-waba-phonenumber-id
          description: Phone number id of WABA account to list campaigns
components:
  schemas:
    Campaign Job:
      title: ''
      type: object
      properties:
        name:
          type: string
        created_at:
          type: string
          format: date-time
        scheduled_at:
          type: string
          format: date-time
        created_by:
          type: string
          description: UUID of agent
        audience:
          title: ''
          type: object
          required:
            - count
            - source
          properties:
            count:
              type: integer
            source:
              type: string
              enum:
                - csv
        campaign:
          title: ''
          type: object
          required:
            - name
            - created_at
            - modified_at
          properties:
            name:
              type: string
            created_at:
              type: string
            modified_at:
              type: string
        status:
          type: string
          enum:
            - completed
            - failed
            - running
            - scheduled
            - cancelled
        delivery_report:
          title: ''
          type: object
          required:
            - running_count
            - completed_count
            - cancelled_count
            - failed_count
            - scheduled_count
          description: >-
            Gives the delivery report for each member of audience, using counter
            (int)
          properties:
            running_count:
              type: integer
            completed_count:
              type: integer
            cancelled_count:
              type: integer
            failed_count:
              type: integer
            scheduled_count:
              type: integer
      required:
        - name
        - created_at
        - scheduled_at
        - created_by
        - audience
        - campaign
        - status
        - delivery_report
      description: Campaign job object
  responses: {}
  parameters:
    Phone number:
      name: X-waba-phonenumber-id
      in: header
      required: false
      schema:
        type: string
      description: Phone number id of WABA account to list campaigns
  examples: {}
  requestBodies: {}
  headers: {}
  securitySchemes: {}
  links: {}
  callbacks: {}
tags: []
servers: []

Try adding example to Path > /jobs > Responses (200) and see the error.

Uncaught (in promise) Error: RangeError: Invalid time value
    at Date.toISOString (<anonymous>)
    at Object.typecast (app.js:2:2968669)
    at e (app.js:2:2982196)
    at app.js:2:2983540
    at Array.forEach (<anonymous>)
    at e (app.js:2:2983439)
    at Object.l [as object] (app.js:2:2978460)
    at e (app.js:2:2982996)
    at Object.s [as array] (app.js:2:2974069)
    at react-openapi-designer/e (https://codeasashu.github.io/react-openapi-designer/app.js:2:2982996) in /properties/data/properties/results/items/0
    at c (app.js:2:2986569)
    at m.generateWithContext (app.js:2:3042515)
    at m.generate (app.js:2:3042550)
    at e.value (app.js:2:1837753)
    at app.js:2:1167696
    at p (app.js:2:7097990)
    at Generator._invoke (app.js:2:7097743)
    at Generator.next (app.js:2:7098353)
    at w (app.js:2:362596)
    at s (app.js:2:362799)