orval icon indicating copy to clipboard operation
orval copied to clipboard

OpenAPI: Can't fetch refs from url

Open iArranzm opened this issue 1 year ago • 4 comments

Hi! hope you can help me with this.

What happens?

When I'm trying to generate my services, I'm getting an error when trying to fetch an schema from an URL like this (changed Ref for privacy)

properties:
        pet:
          allOf:
            - $ref: "https://raw.githubusercontent.com/orval-labs/orval/master/samples/angular-app/petstore.yaml#/components/schemas/Pet"
            - description: pet info

The error is

orval --config orval.config.ts 🍻 Start orval v6.31.0 - A swagger client generator for typescript fakeService: Cleaning output folder 🛑 fakeService - Oops... 🍻. Ref not found: https://raw.githubusercontent.com/orval-labs/orval/master/samples/angular-app/petstore.yaml#/components/schemas/Pet

What were you expecting to happen?

I was expecting that Refs could be retrieved from and URL. At first I thought it was because the URL I was trying to access required me to be connected to the VPN, but when I switch to your test YAML, I get the same error.

Any other comments?

I'm don't think it's a bug, probably it's a feature not supported or I am doing something wrong. If you need further info I'll be glad to provide it.

What versions are you using?

System: OS: macOS 14.5 CPU: (12) arm64 Apple M2 Pro Memory: 61.92 MB / 16.00 GB Shell: 5.9 - /bin/zsh npmPackages: orval: ^6.31.0 => 6.31.0

iArranzm avatar Aug 01 '24 17:08 iArranzm

Similar to https://github.com/orval-labs/orval/issues/863

melloware avatar Aug 01 '24 17:08 melloware

Yeah I am sure its a bug or unimplemented feature.

melloware avatar Aug 01 '24 17:08 melloware

I fear it happens in also in v7.0.1. Wanted to upgrade the version from 6.15.0 (where is was fine), but it can't find $ref.

openapi: 3.1.0
info:
  description: Default description
  version: 1.0.0
  title: Default Title
paths:
  foo:
    get:
      operationId: myOperationId
      summary: Just a summary
      parameters:
        - $ref: '../parameters/path/path-bar.yaml#/components/parameters/path-bar'
      responses:
        '200':
          description: Default response
          content:
            application/json:
              schema:
                $ref: '../schemas/index.yaml#/components/schemas/DefaultDTO' // can't find this one, and it's not a single case

P.S: @melloware since it works in 6.15.0, I would tend to assume it's a bug.

atsoy avatar Aug 15 '24 09:08 atsoy

I marked it as a bug. If you look through Git commits maybe you can find where it broke and submit a PR.

melloware avatar Aug 15 '24 11:08 melloware

for me this happens if --input has at least one slash in the path

orval --input foo/api.yaml # fails
cd foo; ovral --input api.yaml # works

xandris avatar Oct 14 '25 22:10 xandris