swagger-api / swagger-api/swagger-parser
3.1.0 parsing of schema containing dependentRequired adds values not present in document
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
3.1.0 parsing of schema containing dependentRequired adds values not present in spec
using swagger-parser v2.1.1
when parsing a spec with this schema:
DependenciesWithEscapedCharacters:
$schema: https://json-schema.org/draft/2020-12/schema
dependentRequired:
? 'foo
bar'
: - "foo\rbar"
foo"bar:
- foo'bar
Swagger parser loads the dependentRequired map as:
{foo
bar=[foo
bar, foo'bar], foo"bar=[foo
bar, foo'bar]}
Where each key stores an array which incorrectly contains 2 values when it should contain only one.
Samples spec is here:
openapi: 3.1.0
servers:
- url: https://someserver.com/v1
info:
title: openapi 3.1.0 sample spec
version: 0.0.1
description: sample spec for testing openapi functionality, built from json schema
tests for draft2020-12
tags: []
paths: {}
components:
schemas:
DependenciesWithEscapedCharacters:
$schema: https://json-schema.org/draft/2020-12/schema
dependentRequired:
? 'foo
bar'
: - "foo\rbar"
foo"bar:
- foo'bar
This prevents users of this library from correctly implementing dependentRequired.
This came up when writing: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator/pull/241
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
Reproduce the issue with the supplied OpenAPI 3.1.0 schema using swagger-parser v2.1.1, then trace how the dependentRequired map is parsed. Done means each map key contains only its declared dependency value, including the escaped-character cases shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100