json-schema-ref-parser
json-schema-ref-parser copied to clipboard
Fails to bundle past the first file level
I have an open api spec that is like so
swagger: "2.0"
info:
version: 1.0.0
title: Swagger petstore
description: A sample API that demonstrates Swagger Express Middleware features
consumes:
- application/json
produces:
- application/json
definitions:
pet:
$ref: ./demo/pet.yaml
pet-filters:
- name: tags
in: query
description: Filters pets by one or more tags
required: false
type: array
items:
type: string
uniqueItems: true
collectionFormat: csv
- name: type
in: query
description: Filters pets by type (dog, cat, or bird)
required: false
type: string
enum: [cat, dog, bird]
- name: age
in: query
description: Filters pets by age
required: false
type: integer
- name: dob
in: query
description: Filters pets by date of birth
required: false
type: string
format: date
- name: address.city
in: query
description: Filters pets by city
required: false
type: string
- name: address.state
in: query
description: Filters pets by state
required: false
type: string
- name: address.zipcode
in: query
description: Filters pets by zip code
required: false
type: integer
- name: vet.name
in: query
description: Filters pets by veterinarian name
required: false
type: string
- name: vet.address.city
in: query
description: Filters pets by veterinarian city
required: false
type: string
- name: vet.address.state
in: query
description: Filters pets by veterinarian state
required: false
type: string
- name: vet.address.zipcode
in: query
description: Filters pets by veterinarian zip code
required: false
type: integer
parameters:
petName:
name: petName
in: path
description: Name of the pet
required: true
type: string
paths:
/pets:
get:
description: Returns all pets, optionally filtered by one or more criteria
operationId: findPets
parameters:
$ref: '#/definitions/pet-filters'
responses:
default:
description: Returns the matching pets
schema:
type: array
items:
$ref: "#/definitions/pet"
headers:
last-modified:
type: string
description: The date/time that a pet was last modified
delete:
description: Deletes all pets, optionally filtered by one or more criteria
operationId: deletePets
parameters:
$ref: '#/definitions/pet-filters'
responses:
default:
description: Returns the pets that were deleted
schema:
type: array
items:
$ref: "#/definitions/pet"
post:
description: Creates a new pet in the store
operationId: addPet
parameters:
- name: pet
in: body
description: The pet to add to the store
required: true
schema:
$ref: "#/definitions/pet"
responses:
201:
description: Returns the newly-added pet
schema:
$ref: "#/definitions/pet"
headers:
Location:
type: string
description: The URL of the newly-added pet
/pets/{petName}:
parameters:
- $ref: "#/parameters/petName"
get:
description: Returns a pet by name
operationId: findPetByName
responses:
default:
description: Returns the pet data
schema:
$ref: "#/definitions/pet"
headers:
last-modified:
type: string
description: The date/time that the pet was last modified
delete:
description: Deletes a single pet based on the name supplied
operationId: deletePet
responses:
default:
description: Returns the pet that was deleted
schema:
$ref: "#/definitions/pet"
patch:
description: Updates a pet by name
parameters:
- name: pet
in: body
description: The updated pet info
required: true
schema:
$ref: "#/definitions/pet"
responses:
default:
description: Returns the updated pet data
schema:
$ref: "#/definitions/pet"
/pets/{petName}/photos:
parameters:
- $ref: "#/parameters/petName"
post:
description: Upload a new pet photo
operationId: addPetPhoto
consumes:
- multipart/form-data
parameters:
- name: id
in: formData
description: The photo ID (generated automatically)
type: integer
format: int32
minimum: 1
- name: label
in: formData
description: A label for the photo
required: true
type: string
minLength: 1
- name: description
in: formData
description: An optional description of the photo
type: string
- name: photo
in: formData
description: The pet photo
required: true
type: file
minLength: 1
maxLength: 5000000 # ~5MB
responses:
default:
description: Returns the photo information
schema:
properties:
id:
type: integer
format: int32
description: The auto-generated photo ID
label:
type: string
description:
type: string
photo:
type: object
description: Information about the photo (size, file name, etc.)
headers:
Location:
type: string
description: The URL of the newly-added photo
get:
description: Get a list of the photos for a pet
responses:
200:
description: Returns the list of photos
schema:
type: array
items:
properties:
id:
type: integer
format: int32
description: The auto-generated photo ID
label:
type: string
description:
type: string
photo:
type: object
description: Information about the photo (size, file name, etc.)
/pets/{petName}/photos/{id}:
parameters:
- $ref: "#/parameters/petName"
- name: id
in: path
description: The ID of the photo
required: true
type: integer
format: int32
get:
description: Gets a pet photo
operationId: getPetPhoto
produces:
- image/jpeg
- image/gif
- image/png
- image/bmp
responses:
default:
description: Returns the pet photo
schema:
type: file
delete:
description: Deletes a pet photo
operationId: deletePetPhoto
responses:
default:
description: The photo was deleted successfully
The in a subfolder called demo I have the yaml files
demo/pet.yaml has a property that references address.yaml
Yet when I look at the returned object from the bundle function, while pet.yaml has resolved and derefenced successfully, the address property of the pet object is undefined.
I am calling the bundle method without any options.
Is this a bug?
Can you try to make a minimum viable reproduceable issue, and paste that in as a gist or a repo?
We get quite a few issues that are "Here is a giant pile of YAML is this good or bad" and it's super tricky to figure out whats going on let alone what your expectations are or if they're right or not.