Package doens't resolve $ref for relative paths
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.yamlis inside anopenapifolder (so the complete path is./openapi/openapi.yaml) - I'm running the command
openapi2postmanv2 -s openapi/openapi.yaml -o postman.json -pthrough a package.json script
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" }
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.