recurse function can recurse infinitely
See original GitHub issueChecklist
- 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:
- Created 5 years ago
- Comments:12 (12 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@MikeRalphson that seems to have fixed the issue. Thank you.
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 ifv3.6.5resolves this for you?