Forum Discussion

souenzzo's avatar
souenzzo
Visitor
2 years ago

Recursive schemas and contributions to swagger-ui

Hello, I'm working on a project that uses a spec that is recursive, and due an old issue (from 2017 - see note 1), swagger-ui can't render it.

 

It can easily reproduced (as in note 3)

 

I would like to know: I'm the only one using recursive schemas? There is some kind of workaround?

 

I would like to work on a fix to it. But a few days ago I wrote a PR (note 2) to fix another issue, and it seems to be ignored by the main contributors.

 

So before write another PR, I would like to ask: how to not be ignored by the community?

 

 

 

1. https://github.com/swagger-api/swagger-ui/issues/3325

 

2. https://github.com/swagger-api/swagger-ui/pull/8400

 

3. Enter https://editor-next.swagger.io/ and paste this schema

 

openapi: 3.0.3
info: {title: "recur", version: "1.0.0"}
paths:
  /pet:
    put:
      responses:
        default:
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
components:
  schemas:
    Pet:
      type: object
      properties:
        name: {type: number}
        myself: {$ref: "#/components/schemas/Pet"}

 

  • dipcario23's avatar
    dipcario23
    Occasional Visitor

    You're definitely not alone in using recursive schemas! For workarounds, consider using references or simplifying your schema.

    Engaging with the community in discussions can also help get your contributions noticed, similar to how the SSS Contribution Table updates are essential for keeping track of benefits.

  • Hi souenzzo ,

     

    First thanks for the PR, my apologies for our lack of attention there. We're looking for ways to improve, but it's a slow process.

     

    Regarding the recursive issue, you're referring to the following UI showing an empty object? 

    From when last I recall, this is an issue to do with how swagger-client (the resolver part) provides the serializable definition. 

    We've recently updated the underlying engine to use ApiDOM which has the functionality to provide meta-data (like if something is recursive), but it's still using the same channels to provide a JS object to SwaggerUI. All of this is to say, this may be a challenging feature to implement but with the recent changes, it may be feasible. 

     

    If you are interested in a PR, I'd first raise an empty draft PR. And since it's tough to get attention, ping my username (ponelat) until we improve our processes.