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

Package doens't resolve $ref for relative paths #775

Open
henriqueleite42 opened this issue Nov 30, 2023 · 2 comments
Open

Package doens't resolve $ref for relative paths #775

henriqueleite42 opened this issue Nov 30, 2023 · 2 comments

Comments

@henriqueleite42
Copy link

I have the following section in my openapi.yaml:

paths:
  /auth/google:
    $ref: "./paths/auth/google.yaml"

./paths/auth/google.yaml file content:

post:
  tags:
    - Auth
  summary: Sign In/Up with Google
  description: |
    Sign Ins or Sign Ups a user using a google account
  operationId: auth-google
  requestBody:
    content:
      application/json:
        schema:
          $ref: "../../components/schemas/auth-with-3rd-party.yaml"
    required: true
  responses:
    $ref: "../../components/responses/auth.yaml"

But the json output is (just a section of it, not the entire file):

{
    "item": [
        {
            "name": "auth",
            "description": "",
            "item": []
        },
    ]
}

So the CLI isn't being able to import the content of ./paths/auth/google.yaml, and it should be.

Extra information:

  • My openapi.yaml is inside an openapi folder (so the complete path is ./openapi/openapi.yaml)
  • I'm running the command openapi2postmanv2 -s openapi/openapi.yaml -o postman.json -p through a package.json script
@dom-bjss
Copy link

dom-bjss commented Apr 8, 2024

I have the same issue. For now, I am working around it by using redocly which is able to 'bundle' (i.e. flatten everything) into one file.
So I flatten it using redocly-cli, which reads in and resolves all the $refs to other files, then I use openapi2postmanv2.

Something like this in my package.json. Hope it's useful :)
{
"scripts": {
"flatten": "redocly bundle my-openapi-spec.yaml -o flattened-spec.yml",
"generate-postman": "npm run flatten && openapi2postmanv2 -s flattened-spec.yml -o collection.json -p -O folderStrategy=Tags"
},
"devDependencies": {
"openapi-to-postmanv2": "4.15.0",
"@redocly/cli": "^1.11.0"
}

@henriqueleite42
Copy link
Author

Thanks @dom-bjss, I'm actually doing the same thing for now hahaha

But would be very helpful if they fixed this issue, so we don't have to bundle to generate the collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants