swagger-parser
swagger-parser copied to clipboard
'#/paths/~1path/get/requestBody/content/application~1json/schema' not resolved with ResolverFully
Bug
The local refs to another schema inside a path definition is not resolved using ResolverFully
. This types of refs are discouraged, but they can be done according to spec and docs https://swagger.io/docs/specification/using-ref/
Steps to reproduce
Try to load with setResolveFully true this spec:
openapi: 3.0.0
info:
version: 1.0.0
title: JSON Schemas test spec
license:
name: MIT
paths:
/test1:
get:
operationId: test1
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Person'
responses:
default:
description: "OK"
/test4:
get:
operationId: test4
responses:
default:
description: "OK"
requestBody:
content:
application/json:
schema:
allOf:
- $ref: '#/paths/~1test1/get/requestBody/content/application~1json/schema'
- $ref: '#/components/schemas/Citizen'
components:
schemas:
Person:
type: object
additionalProperties: {}
properties:
name:
type: string
surname:
type: string
required:
- name
- surname
Citizen:
type: object
additionalProperties: {}
properties:
id_card:
type: string
required:
- id_card
Thanks for the report. Since, as you mentioned, this type of $refs is discouraged, we won't be able to prioritize a fix for this over other issues. If, however, you'd like to submit a PR that resolves it, we'd be happy to review and merge.
My bad that PR doesn't address this issue
If you can find useful, here is another reproducer: debts_manager_api.zip. The only error message is "All elements are null". I generated this spec starting with speccy.io
Can you please provide the reference which says this type of ref is discouraged? I can't find it and I think it's still a valid usage.