Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting $ref for paths #497

Open
paragon opened this issue Jan 6, 2025 · 5 comments
Open

Supporting $ref for paths #497

paragon opened this issue Jan 6, 2025 · 5 comments
Labels
feature New feature or request

Comments

@paragon
Copy link

paragon commented Jan 6, 2025

I'm attempting to migrate away from Redocly to zudoku, and seem to have encountered an issue using $ref in individual paths. I describe my issue below in what appears to be a bug, but please do let me know if I am making a simple mistake!

As seen at https://swagger.io/docs/specification/v3_0/using-ref/#considerations, it is valid syntax to have the following:

paths:
  /users:
    $ref: "../resources/users.yaml"
  /users/{userId}:
    $ref: "../resources/users-by-id.yaml"

To start, I created an example Project using:

npm create zudoku-app@latest

...with my project name being example.

As such, the generated file structure contains apis/openapi.yaml. Within api/, I created a folder called paths, with a file inside it called user.yaml, as such:

example
- apis/
--- openapi.yaml
--- paths/
----- user.yaml
<remaining generated files that are untouched>

To illustrate the issue I am encountering, I am using the simple example seen at https://swagger.io/docs/specification/v3_0/basic-structure/#_top. I would expect to see the /users path rendered when navigating to localhost:9000/api - however, I only see the Overview page (which shows Sample API and the description of Optional multiline or single-line description in CommonMark or HTML.).

Below are the relevant apis/openapi.yaml and apis/paths/user.yaml files generated from said example.

apis/openapi.yaml

openapi: 3.0.0
info:
  title: Sample API
  description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
  version: 0.1.9

servers:
  - url: http://api.example.com/v1
    description: Optional server description, e.g. Main (production) server
  - url: http://staging-api.example.com
    description: Optional server description, e.g. Internal staging server for testing

paths:
  /users:
    $ref: 'paths/user.yaml'

apis/paths/user.yaml

get:
  summary: Returns a list of users.
  description: Optional extended description in CommonMark or HTML.
  responses:
    "200": # status code
      description: A JSON array of user names
      content:
        application/json:
          schema:
            type: array
            items:
              type: string
Copy link

linear bot commented Jan 6, 2025

@mosch mosch added the feature New feature or request label Jan 8, 2025
@mosch
Copy link
Contributor

mosch commented Jan 8, 2025

Hey @paragon - today we don't support files in references. You can get things working by putting everything into one file.

Definitely a change we want to make soon, so we're happy to accept a PR for this.

@mosch
Copy link
Contributor

mosch commented Jan 22, 2025

Hey @paragon we made some changes that allows us to get this working soon. Are you still planning to migrate to Zudoku?

@paragon
Copy link
Author

paragon commented Jan 22, 2025

Hey @mosch - I sure am! I don't have the throughput to work on a PR currently, but we are still very interested in using Zudoku :-)

@mosch
Copy link
Contributor

mosch commented Jan 22, 2025

Awesome, we started working on it here: #578

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

No branches or pull requests

2 participants