Bug: Maximum call stack size exceeded when converting openapi 3.0.1 with circular references
Current Behavior
When trying to convert openapi 3.0.1 with circular dependencies RangeError is produced. The same exact openapi with only the version changed to openapi: 3.1.0 works correctly.
Exxpected Behavior
openapi 3.0.1 with circular references should convert without errors.
Steps to Reproduce
cat << 'EOF' > /tmp/s18.yaml
openapi: 3.0.1
info:
title: Test 18 - Minimal 3.0.1
version: 1.0.0
servers:
- url: http://localhost
paths:
/test:
get:
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/TypeA"
components:
schemas:
TypeA:
type: object
properties:
name:
type: string
next:
$ref: "#/components/schemas/TypeB"
TypeB:
type: object
properties:
value:
type: integer
next:
$ref: "#/components/schemas/TypeC"
TypeC:
type: object
properties:
description:
type: string
next:
$ref: "#/components/schemas/TypeA"
EOF
adc convert openapi -o /dev/stdout -f /tmp/s18.yaml
[3:48:12 PM] [ADC] › ▶ start Convert OpenAPI document "/tmp/s18.yaml"
[3:48:12 PM] [ADC] › ✖ error Convert OpenAPI document "/tmp/s18.yaml"
[3:48:12 PM] [ADC] › ✖ fatal RangeError: Maximum call stack size exceeded
cat << 'EOF' > /tmp/s19.yaml
openapi: 3.1.0
info:
title: Test 19 - Minimal 3.1.0
version: 1.0.0
servers:
- url: http://localhost
paths:
/test:
get:
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/TypeA"
components:
schemas:
TypeA:
type: object
properties:
name:
type: string
next:
$ref: "#/components/schemas/TypeB"
TypeB:
type: object
properties:
value:
type: integer
next:
$ref: "#/components/schemas/TypeC"
TypeC:
type: object
properties:
description:
type: string
next:
$ref: "#/components/schemas/TypeA"
EOF
adc convert openapi -o /dev/stdout -f /tmp/s19.yaml
[3:48:13 PM] [ADC] › ▶ start Convert OpenAPI document "/tmp/s19.yaml"
[3:48:13 PM] [ADC] › ✔ success Convert OpenAPI document "/tmp/s19.yaml"
[3:48:13 PM] [ADC] › ▶ start Write converted OpenAPI file
services:
- name: Test 19 - Minimal 3.1.0
routes:
- methods:
- GET
name: Test-19-Minimal-3.1.0_test_get
uris:
- /test
upstream:
nodes:
- host: localhost
port: 80
weight: 100
pass_host: pass
scheme: http
timeout:
connect: 60
read: 60
send: 60
[3:48:13 PM] [ADC] › ✔ success Converted OpenAPI file to "/dev/stdout" successfully
[3:48:13 PM] [ADC] › ★ star All is well, see you next time!
Environment
- APISIX version:
apache/apisix:3.13.0-ubuntu - ADC version (run
adc version):0.21.1 - Operating system (run
uname -a):Linux bluelap 6.8.0-83-generic #83~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Sep 9 18:19:47 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
This parser and converter utilize the implementation from the upstream library; we only perform the conversion using the final output. I will investigate to determine if this is an issue of improper usage on our part.
If not, you may need to report this issue to the upstream project.
@bzp2010 did you manage to verify this? it is not crucial for me but I would like to follow up somewhere to fix this.