cancel
Showing results for 
Search instead for 
Did you mean: 

No error in swagger-parser when $ref to nothing

Highlighted
Frequent Visitor

No error in swagger-parser when $ref to nothing

I encountered a problem in swagger-parser where a $ref to an object that does not exist at all did not throw an error - is this a bug, a configuration error, or do I need to run validation with something else first?

Tags (1)
1 REPLY 1
Highlighted
Occasional Visitor

Hi, I tested this with the following spec:

openapi: 3.0.0
info:
version: 1.0.0
title: Issue 1190
license:
name: Apache-2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/example:
get:
operationId: example
responses:
'200':
description: successful operation
content:
'application/json':
schema:
$ref: "#/components/schemas/XomeObj"
components:
schemas:
SomeObj1:
type: object
properties:
lorem:
type: array
minItems: 1
additionalProperties: false
items:
type: object
properties:
firstName:
type: string
lastName:
type: string  

 And parser threw a warning:

- attribute paths.'/example'(get).responses.200.content.'application/json'.schema.#/components/schemas/XomeObj is missing

Please try updating to the latest parser version.

And let us know if this fixes the issue, or if the case happening to you is different.

New Here?
Join us and watch the welcome video:
Announcements