-
Notifications
You must be signed in to change notification settings - Fork 14
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
Schema with recursion hangs building #41
Comments
Thanks for the feedback 🙌 If possible, that would indeed be a nice enhancement. I remember that the parser we use has various options regarding circular references, so may need to play around with that and see if some of them could help 👍 |
I'm trying to include a really big OpenAPI spec file with this plugin and was running into #31 when building a static site or visiting the operations with the offending components in the dev server. After some investigation, it seems the memory issue was just a consequence of this recursion issue in this case. Sharing my test results in the hope it helps someone:
Complete buggy example: openapi: 3.1.0
info:
title: Test Recursion
description: Example of the recursion issue from starlight-openapi.
version: 1.0.0
servers:
- url: 'http://localhost'
paths:
/categories:
get:
summary: List all categories
operationId: listCategories
parameters:
- name: limit
in: query
description: How many categories to return at one time (max 100)
schema:
type: integer
maximum: 50
format: int32
nullable: true
- name: offset
in: query
description: The number of categories to skip before starting to collect the result set
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of categories
content:
application/json:
schema:
$ref: '#/components/schemas/Categories'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/posts:
get:
summary: List all posts
operationId: listPosts
parameters:
- name: limit
in: query
description: How many posts to return at one time (max 100)
schema:
type: integer
maximum: 50
format: int32
nullable: true
- name: offset
in: query
description: The number of posts to skip before starting to collect the result set
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of posts
content:
application/json:
schema:
$ref: '#/components/schemas/Posts'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Category:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
posts:
$ref: '#/components/schemas/Posts'
Categories:
type: array
maxItems: 100
items:
$ref: '#/components/schemas/Category'
Post:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
text:
type: string
category:
$ref: '#/components/schemas/Category'
Posts:
type: array
maxItems: 100
items:
$ref: '#/components/schemas/Post'
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string |
Describe the bug
When I try to build a schema which includes recursion the process hangs.
To Reproduce
Build the following schema:
The component
TreeNodeInput
has a childnodes
which is an array of the same type.Expected behavior
Maybe it'd make sense to detect the recursion and stop generating additional levels, so the process doesn't get into infinite recursion.
How often does this bug happen?
Every time
System Info
Version: 0.6.4
Additional Context
No response
The text was updated successfully, but these errors were encountered: