swagger-api / swagger-api/swagger-client

OpenAPI 3.1.0: error when resolving schemas with allOf and circular references

Open
#3,858 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: resolver type: bug version: 3.x
Dominant language
JavaScript
Stars
2.7k
Forks
765
Avg merge
1d 1h
Merged PRs (30d)
6

Description

NOTE: this will also be affecting ApiDOM OpenAPI 3.0.x dereferencing. Another issues needs to be create for ApiDOM repo.

Content & configuration

Swagger/OpenAPI definition:

openapi: 3.1.0
components:
  schemas:
    First:
      allOf:
        - $ref: '#/components/schemas/Second'
    Second:
      allOf:
        - $ref: '#/components/schemas/Third'
    Third:
      allOf:
        - $ref: '#/components/schemas/Second'

Describe the bug you're encountering

Resolving a subtree or the entire definition will cause an error TypeError: Elements in allOf must be objects.

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor-next.swagger.io/
  2. Paste the definition
  3. Open any of the schemas
  4. See the error
Screenshots

The result of opening Second and then Third schema:

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the circular allOf example in editor-next.swagger.io by opening the Second and Third schemas. Trace the schema resolution or dereferencing entry point that produces “Elements in allOf must be objects”; done means resolving the subtree or full definition without that error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.