Hello,
I am getting am issue from last week. I am creating documentation for my project. I am using Swagger Editor online. I have some definitions which are interrelated. Means one definition has reference of other definition. Then the response of the path has reference of the definition. But when I take a look at it in demo UI which is shown in the editor, the reference shows undefined. I have given one reference code as example . Please take a look at it in the online editor. You can see that under getUserList list in response the user definition is shown as undefined. I guess this issue is because I have references in both definitions. If I remove the userGroup reference from the user definition, I am able to see user in response. This issue wasn't there a week before. Is anything changed ? Am I suppose to make any other changes to make it work. Please look into this issue because it is a major component of my documentation. Let me know if you need anymore details.
Thankyou.
Yaml code
swagger: '2.0'
info:
title: REST API
description: REST API Documentation
version: '1.0'
host: 'admin.sd.net:81'
schemes:
- http
- https
produces:
- application/json
paths:
/getUserList:
get:
summary: Get User List
description: Get User List
parameters:
- name: currentId
in: query
description: >-
Provide current Id
required: false
type: integer
tags:
- User
responses:
'200':
description: Retrieval successful
schema:
type: array
items:
$ref: '#/definitions/user'
default:
description: Unexpected error
definitions:
userGroup:
type: object
properties:
id:
type: integer
createdBy:
type: integer
createdOn:
type: string
format: date
modifiedBy:
type: integer
modifiedOn:
type: string
format: date
state:
type: integer
name:
type: string
description:
type: string
users:
$ref: '#/definitions/user'
createdByUser:
type: string
modifiedByUser:
type: string
user:
type: object
properties:
id:
type: integer
createdBy:
type: integer
createdOn:
type: string
format: date
modifiedBy:
type: integer
modifiedOn:
type: string
format: date
state:
type: integer
firstName:
type: string
lastName:
type: string
emailAddress:
type: string
users:
$ref: '#/definitions/userGroup'
This is the result of this change in JSON Refs.
It used to resolve circular dependencies until a few levels that was working in editor unless you dig in really deep.
Then it was changed to resolving to empty object which break previous behavior and now it resolves to {circular: true} that to our renderer doesn't mean anything.
If we can get back the original behavior (resolving up to n levels) or at least have that as an option in JSON Refs, we can't do much.
/cc @whitlockjc
Ok. Thanks for opening a bug. Will be waiting for your further response.
My understanding of this change is that the end result is to have the #ref in place, not an empty object. Has it not been released yet?
I also noticed this problem! I think self-reference is a pretty common practice.
Follow this issue here: https://github.com/whitlockjc/json-refs/issues/91
Commenting to add another voice to this; I'm having the same issue.
Note that https://github.com/whitlockjc/json-refs/issues/91 has been closed as a duplicate of https://github.com/whitlockjc/json-refs/issues/74.
Screenshot of my issue: 
just ran over this issue because my API has some nice circular references, this is pretty annoying :/
I am getting same issue.
Is there no one actually fixing this?
So.. as of right now in 2017, circular dependencies are broken in swagger-ui with no workaround? This is like the most basic thing that appears in any API. Can we at least roll back the dependency version which introduced the breaking change or would that break other things?
You'll see a fix shortly
Any updates on this? @fehguy
Circular references should no longer be an issue in master.
Not quite yet. It works in only one direction. For example:
User:
type: object
description: Abc
properties:
cards:
type: array
items:
$ref: '#/definitions/Card'
Card:
type: object
description: Efg
properties:
user:
$ref: '#/definitions/User'
When User object is returned, response JSON correctly contins a card object. When Card object is returned, there is no User object in JSON.
@webron
Can you point me out which code fixes it?
I would like to pull it to 2.x version.
Or it's not possible already?
It looks like you rewrote the whole thing (I saw two commits: out with the old, in with the new).
@gordey4doronin - It will not be possible to pull it into 2.x.
@cen1 - there's definitely an issue with what you shared, and we're looking into it.
This should no longer be an issue with 3.X. However, if the issue persists, please file a new ticket.
Most helpful comment
I am getting same issue.