question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for multiple $refs inside a single object

See original GitHub issue

It would be really useful to be able to do something like this:

paths:
    $ref: "/operations/pets.yaml"       # Multiple paths
    $ref: "/operations/stores.yaml"     # Multiple paths
    $ref: "/operations/users.yaml"      # Multiple paths

Where each file includes multiple paths. For example (pets.yaml):

/pets:
  post:
    # ...
/pets/findByStatus:
  get:
    # ...

This would make it easier to organize a large API.

Edit:

It could also be an array, like this:

paths:
    $ref:
        - "/operations/pets.yaml"
        - "/operations/stores.yaml"
        - "/operations/users.yaml"

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:129
  • Comments:37 (9 by maintainers)

github_iconTop GitHub Comments

29reactions
picardplaisimondcommented, May 29, 2021

It’s 2021, and we still don’t have a solution for this problem. I also think that we should be (at least) able to use arrays for this.

14reactions
glen-84commented, Jul 17, 2015

It’s quite surprising to me that the existing standards don’t support this. I don’t suppose this is likely to change?

As for merge conflicts, if I create two equal paths with the Swagger editor, it just uses the last one. It could be the same, or it could be a setting if you want it to throw an error.

Nested paths might be an option, although it feels a bit weird having the nested paths at the same level as post/get etc.

Could allOf be used at all?

paths:
    allOf:
        - $ref: "/operations/pets.yaml"
        - $ref: "/operations/stores.yaml"
        - /users:
            get:
                # ...

… that may be completely incorrect or make no sense – I don’t know very much about JSON schema. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using multiple refs on a single React element - Stack Overflow
A React ref is really nothing but a container for some mutable data, stored as the current property. See the React docs for...
Read more >
Set multiple React refs in one variable - clubmate.fi
Storing multiple refs to an array or an object. You can use an array or an object to store React refs, depending on...
Read more >
Storing Multiple Refs in an Array With React's useRef() Hook
An associative array is a convenient way to group multiple refs into a single variable. This way, each element can be accessed through...
Read more >
Using $ref - Swagger
In that case, you can create a snippet for such elements in order to use them multiple times when you need it. With...
Read more >
How to create an array of React refs - YouTube
Learn how to target multiple elements using React refs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found