Closed iammelvin closed 3 years ago
There's a lot of different types of circular references so an example would be super handy. If you have a recreateable file or something?
Cannot recreate.
@philsturgeon - here's an example:
openapi: 3.0.0
info:
title: Employees API
version: 0.0.1
paths:
/employees:
get:
summary: Returns a list of employees.
responses:
'200':
description: A JSON array of employees
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Employee'
components:
schemas:
Employee:
type: object
properties:
id:
type: string
name:
type: string
manager:
$ref: '#/components/schemas/Employee'
This will give the following error because of the manager
property under the Employee
type:
This API is valid, but it cannot be shown because it contains circular references
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'properties' -> object with constructor 'Object'
--- property 'manager' closes the circle
at JSON.stringify (<anonymous>)
at toText (https://apitools.dev/swagger-parser/online/js/bundle.min.js:29:40049)
at editors.addResult (https://apitools.dev/swagger-parser/online/js/bundle.min.js:29:41185)
at editors.showResult (https://apitools.dev/swagger-parser/online/js/bundle.min.js:29:40466)
at https://apitools.dev/swagger-parser/online/js/bundle.min.js:29:44991
at Array.forEach (<anonymous>)
at https://apitools.dev/swagger-parser/online/js/bundle.min.js:29:44971
I am using the online tool at apitools.dev for validating my open API spec and I get the below error but when testing the same with swagger editor I am not getting any errors. OData with . Net Core is been used for REST API's. Need some help to understand whether I have anything wrong in my swagger json file or its some issue with the tool itself.
This API is valid, but it cannot be shown because it contains circular references