question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

recurse function can recurse infinitely

See original GitHub issue

Checklist

  • Conversion: I have checked my source definition is valid OpenAPI 2.0

Detailed Description

When a valid OpenAPI 2.0 spec contains a definition which is self-referencing, the recurse function will go on forever (well, until the stack runs out) due to the fact that it has no maxDepth functionality. There needs to be some way like tracking maxDepth or recognizing that it is in an infinite recursion to break out.

Simple valid OpenAPI 2.0 spec illustrating issue:

{
  "info": {
    "title": "Example title",
    "description": "Example description.",
    "version": "v1"
  },
  "swagger": "2.0",
  "produces": [
    "application/xml",
    "application/json",
    "application/octet-stream",
    "text/plain"
  ],
  "host": "example.org",
  "basePath": "/example/v1",
  "schemes": [
    "https"
  ],
  "tags": [
    {
      "name": "examples",
      "description": "Operations about examples"
    }
  ],
  "paths": {
    "/examples": {
      "post": {
        "summary": "Create an example",
        "description": "Create an example using a POST request",
        "produces": [
          "application/json"
        ],
        "consumes": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "Example",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Example"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "description": "Bad Request"
          }
        },
        "tags": [
          "examples"
        ],
        "operationId": "postExample"
      }
    }
  },
  "definitions": {
    "Example": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "sub_examples": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Example"
          }
        }
      },
      "required": [
        "id",
        "sub_examples"
      ],
      "description": "Create an example"
    }
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
jdmurphycommented, Nov 14, 2018

@MikeRalphson that seems to have fixed the issue. Thank you.

0reactions
MikeRalphsoncommented, Nov 5, 2018

I’ve added detection of already seen objects to the recursion which is done to limit request/response examples to that given in options.maxDepth. Could you let me know if v3.6.5 resolves this for you?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Finite and Infinite Recursion with examples - GeeksforGeeks
Infinite Recursion occurs when the recursion does not terminate after a finite number of recursive calls. As the base condition is never met, ......
Read more >
the method will recurse infinitely - java - Stack Overflow
I want to write it again as a recursive method and then write a full program that take input from the user and...
Read more >
What is infinite recursion? - Quora
Infinite recursion happens when a recursive function fails to stop recursing. Unless the design specification for the function says it should abuse resources ......
Read more >
IC210: Functions V - Recursion
This function has an infinite recursion, meaning that recursive calls are made over and over again, without any mechanism to stop the process....
Read more >
recursion.md - gists · GitHub
A recursive function is a function that makes a call to itself. To prevent infinite recursion, you need at least one branch (i.e....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found