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

Infinite loop on Recursive Data Type with file reference #1291

Closed
karaatanassov opened this issue Jul 28, 2020 · 1 comment
Closed

Infinite loop on Recursive Data Type with file reference #1291

karaatanassov opened this issue Jul 28, 2020 · 1 comment
Labels
t/bug Something isn't working

Comments

@karaatanassov
Copy link

karaatanassov commented Jul 28, 2020

Describe the bug
Spectral falls into infinite loop when the supplied definition contain recursive model e.g. linked list with a file reference.

The same recursive model processes well with local references

To Reproduce

  1. Given this OpenAPI/AsyncAPI document (save as "linked_list.yml")

linked_list.yml

openapi: 3.0.0
servers:
  - url: http://test.com/linked-list
    description: test service
tags:
  - name: LinkedList
    description: Linked List operations
info:
  title: Linked List DataObject Test
  version: version.version0
  contact: 
    name: Kiril Karaatanassov
  description: test recursive data structures
components:
  schemas:
    Node:
      description: 'Linked list node'
      example: {}
      properties:
        label:
          type: string
        next:
          $ref: 'linked_list.yml#/components/schemas/Node'
      required:
      - label
      type: object
paths:
  /test/linked-list:
    get:
      operationId: getLinkedList
      description: Returns a linked list that can be exception or trust chain
      tags: ["LinkedList"]
      responses:
        '200':
          description: Wow success!!!
          content:
            "application/json":
              schema:
                $ref: '#/components/schemas/Node'
  1. Run this CLI command './spectral lint linked_list.yml'
  2. See error - spectral runs indefinitely, no output is produced

Expected behavior
validate the OpenAPI spec in finite time.

The same spec with removed file name from the recursive reference validates in couple of seconds

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (remove any that are not applicable):

  • Library version: 5.4.0
  • OS: Ubuntu 18.04

Additional notes

I found the following issue to be possibly related. In my case with 5.4.0 recursive types (i.e. circular reference) within the same file seem to work fine.

#915

One of the comments mentions use of different library for handling JSON schema references

#1054

Again I do not see problems if the file name is removed form the schema. Problem is that to remove all filenames we have to flatten a relatively big API into single file (~8000 schemas and ~1000 operations)

@karaatanassov karaatanassov added the t/bug Something isn't working label Jul 28, 2020
@philsturgeon
Copy link
Contributor

This will be solved by #1054 which handles circular references better. v6.0 is next up now that v5.6 has been released, so hopefully it'll come soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants