swagger-api / swagger-api/swagger-parser
Can't reference parent through child
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Here's a simplified version of my code. I have this file structure:
└─ openapi
├─ index.yaml
├─ schemas.yaml
└─ paths.yaml
Here is index.yaml:
openapi: 3.0.0
info:
version: 1.0.0
title: Test API
components:
schemas:
$ref: './schemas.yaml'
paths:
$ref: './paths.yaml'
Here is schemas.yaml:
User:
description: A user of the current system
type: object
properties:
name:
type: string
required:
- name
Here is paths.yaml:
/user:
get:
summary: Get current user
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/User'
This is the returned error from paths.yaml: MissingPointerError: Token "components" does not exist. As soon as I remove the reference, it's working.
According to the specifications:
Reference – $ref: '#/definitions/myElement' # means go to the root of the current document and then find elements definitions and myElement one after one.`
This should work.
I just made a (non)working exemple: https://github.com/jumpman255/swagger-parser-child-bug
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction and its openapi/index.yaml, schemas.yaml, and paths.yaml files; run the example to reproduce the MissingPointerError for the child document reference. Trace how swagger-parser resolves $ref values across these files, and consider the issue done when '#/components/schemas/User' resolves successfully from paths.yaml without removing the reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, yaml
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100