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

null is not an object (evaluating 'Object.keys(n)') from validated OpenAPI 3.0 schema #206

Closed
leagerl1 opened this issue Feb 20, 2018 · 4 comments

Comments

@leagerl1
Copy link

Lincoln fails to render our OpenAPI 3.0 spec with the error null is not an object (evaluating 'Object.keys(n)') despite the fact that this is a validated schema and is renderable by the latest Swagger-UI supporting OpenAPI 3.0. We'd like to use Lincoln for rendering our API specs but can't because of this error. Any idea what causes this?

@quangkhoa
Copy link
Contributor

quangkhoa commented Feb 20, 2018

Hi @leagerl1, would you be able to provide your OpenAPI spec file?

@leagerl1
Copy link
Author

Here is a sample spec that works with swagger-ui but not with Lincoln

openapi: 3.0.0
servers:
  - url: https://api{environment}.myapi.com/v1/management
    description: Sandbox environment for testing and developing configurations
    variables:
      environment:
        enum:
          - -sandbox
          - -staging
        default: ''
info:
  description: >-
    API for managing profile information
  version: 1.0.0
  title: Profile Management
tags:
  - name: User
    description: >-
      Actions for clients authorized by the user to create and update data on
      the user's behalf.
paths:
  /user:
    post:
      tags:
        - User
      summary: Add a new additional data user
      description: >-
        Action for registering new user accounts
      operationId: addUser
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - user_auth:
            - 'write:all'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'
        description: User to be registered with the RAD
        required: true
  /locations:
    get:
      tags:
        - Location
      summary: Retrieve Location records
      description: Retrieve all location records belonging to the authenticated user
      operationId: getUserLocations
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Location'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - user_auth:
            - 'read:all'
    post:
      tags:
        - Location
      summary: Create a new Location record
      description: >-
        Create a new record of location information including address,
        floorplan, and emergency contact info for the authenticated user
      operationId: addUserLocation
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Location'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - user_auth:
            - 'write:all'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Location'
        description: Personal info of the user to add
        required: true
  '/locations/{locationId}':
    parameters:
      - in: path
        name: locationId
        required: true
        description: Unique ID of the Location record to modify
        schema:
          type: integer
    delete:
      tags:
        - Location
      summary: Delete Location record
      description: Delete a full Location record belonging to the authenticated user
      operationId: deleteUserLocation
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Location'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - user_auth:
            - 'write:all'
    get:
      tags:
        - Location
      summary: Retrieve Location record
      description: >-
        Retrieve a full existing Location record for the authenticated user by
        ID
      operationId: getUserLocation
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Location'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - user_auth:
            - 'read:all'
    patch:
      tags:
        - Location
      summary: Partially update an existing Location record
      description: >-
        Update only specific attributes of the Location record with a partial
        update
      operationId: partialUpdateUserLocation
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Location'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - user_auth:
            - 'write:all'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Location'
        description: Location attributes to update
        required: true
    put:
      tags:
        - Location
      summary: Full update of an existing Location record
      description: >-
        Completely overwrite an existing Location record with the provided
        attributes
      operationId: updateUserLocation
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Location'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - user_auth:
            - 'write:all'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Location'
        description: Location record attributes to overwrite existing record with
        required: true
components:
  securitySchemes:
    emergency_auth:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: 'https://api-sandbox.myapi.com/oauth/token'
          scopes: {}
    user_auth:
      type: oauth2
      flows:
        password:
          tokenUrl: 'https://api-sandbox.myapi.com/oauth/token'
          scopes: {}
  schemas:
    Address:
      type: object
      properties:
        label:
          type: string
          description: 'Home, work, etc.'
        street_address:
          type: string
          description: Full street address
        locality:
          type: string
          description: 'City, town, etc.'
        region:
          type: string
          description: 'State, province, etc.'
        postal_code:
          type: string
          description: Short or long form
        country_code:
          type: string
          description: ISO ALPHA-2 country code
        latitude:
          type: number
          format: float
          description: 'EPSG:4326 ISO6709 latitude coordinate'
        longitude:
          type: number
          format: float
          description: 'EPSG:4326 ISO6709 longitude coordinate'
        note:
          type: string
          description: Free form descriptor
      required:
        - label
        - street_address
        - locality
        - region
        - postal_code
        - country_code
    Animal:
      type: object
      properties:
        label:
          type: string
          description: 'Service animal, livestock, etc.'
        full_name:
          type: string
          description: Name of the animal
        species:
          type: string
          format: E.164
          description: Animal species
        photo:
          type: string
          format: Email
          description: URL to photo of the animal
        note:
          type: string
          description: Free form descriptor
      required:
        - label
        - full_name
        - species
    Email:
      type: object
      properties:
        label:
          type: string
          description: 'Personal, work, etc.'
        email_address:
          type: string
          format: Email
          description: Email address
        note:
          type: string
          description: Free form descriptor
      required:
        - label
        - email_address
    EmergencyContact:
      type: object
      properties:
        label:
          type: string
          description: Contact relationship
        full_name:
          type: string
          description: Full name of the emergency contact
        phone:
          type: string
          format: E.164
          description: E.164 formatted phone number
        email:
          type: string
          format: Email
          description: Email address
        note:
          type: string
          description: Free form descriptor
      required:
        - label
        - full_name
        - phone
    ErrorResponse:
      type: object
      properties:
        detail:
          type: string
      required:
        - detail
    Location:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        address:
          type: object
          properties:
            value:
              type: array
              items:
                $ref: '#/components/schemas/Address'
            type:
              type: string
              default: address
              readOnly: true
            display_name:
              type: string
              default: Address
              readOnly: true
        animal:
          type: object
          properties:
            value:
              type: array
              items:
                $ref: '#/components/schemas/Animal'
            type:
              type: string
              default: animal
              readOnly: true
            display_name:
              type: string
              default: Animals
              readOnly: true
        comment:
          type: object
          properties:
            value:
              type: array
              items:
                type: string
            type:
              type: string
              default: string
              readOnly: true
            display_name:
              type: string
              default: Comments
              readOnly: true
        external_data_portal:
          type: object
          properties:
            value:
              type: array
              items:
                $ref: '#/components/schemas/URL'
            type:
              type: string
              default: web-url
              readOnly: true
            display_name:
              type: string
              default: External Data Portal
              readOnly: true
        fixed_video_feed:
          type: object
          properties:
            value:
              type: array
              items:
                $ref: '#/components/schemas/VideoStream'
            type:
              type: string
              default: video-stream
              readOnly: true
            display_name:
              type: string
              default: Fixed Video Feed
              readOnly: true
        floorplan:
          type: object
          properties:
            value:
              type: array
              items:
                $ref: '#/components/schemas/URL'
            type:
              type: string
              default: image-url
              readOnly: true
            display_name:
              type: string
              default: Floorplans
              readOnly: true
        location_contact:
          type: object
          properties:
            value:
              type: array
              items:
                $ref: '#/components/schemas/EmergencyContact'
            type:
              type: string
              default: emergency-contact
              readOnly: true
            display_name:
              type: string
              default: Emergency Contacts
              readOnly: true
        location_name:
          type: object
          properties:
            value:
              type: array
              items:
                type: string
            type:
              type: string
              default: string
              readOnly: true
            display_name:
              type: string
              default: Name
              readOnly: true
        mobile_video_feed:
          type: object
          properties:
            value:
              type: array
              items:
                $ref: '#/components/schemas/VideoStream'
            type:
              type: string
              default: video-stream
              readOnly: true
            display_name:
              type: string
              default: Mobile Video Feed
              readOnly: true
        updated_time:
          type: integer
          description: >-
            Millisecond-precise UNIX timestamp of when the record was last
            updated
          readOnly: true
    PhoneNumber:
      type: object
      properties:
        label:
          type: string
          description: 'Home, work, etc.'
        number:
          type: string
          format: E.164
          description: E.164 formatted phone number
        note:
          type: string
          description: Free form descriptor
      required:
        - label
        - number
    RealtimeMetric:
      type: object
      properties:
        label:
          type: string
          description: Data feed source descriptor
        data_feed:
          type: string
          description: URL for retrieving real-time data
        protocol:
          type: string
          description: 'Protocol for requesting this data from the URL i.e. https, wss'
          enum:
            - http
            - https
            - ws
            - wss
        note:
          type: string
          description: Free form descriptor
      required:
        - label
        - data_feed
        - protocol
    URL:
      type: object
      properties:
        label:
          type: string
          description: 'Personal, work, etc.'
        url:
          type: string
          format: URL
          description: Full URL address
        note:
          type: string
          description: Free form descriptor
      required:
        - label
        - url
    User:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        username:
          type: string
        email:
          type: string
        password:
          type: string
        created:
          type: string
          readOnly: true
        modified:
          type: string
          readOnly: true
      required:
        - username
        - email
        - password
    VideoStream:
      type: object
      properties:
        label:
          type: string
          description: Video feed source descriptor
        url:
          type: string
          description: URL for accessing video stream
        format:
          type: string
          format: E.164
          description: Video format the stream is in i.e. mp4
        latitude:
          type: number
          format: float
          description: 'EPSG:4326 ISO6709 latitude coordinate'
        longitude:
          type: number
          format: float
          description: 'EPSG:4326 ISO6709 longitude coordinate'
        note:
          type: string
          description: Free form descriptor
      required:
        - label
        - url
        - format

@quangkhoa
Copy link
Contributor

Hi @leagerl1 sorry it took a while for me to jump on this one. I think I found the issue.

Can you pls try again at https://temando.github.io/open-api-renderer/demo/

@leagerl1
Copy link
Author

@quangkhoa That seems to have fixed it! Thank you

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

2 participants