swagger-api / swagger-api/swagger-parser

3.1.0 parsing of document with max/minContains removes constraint if value is a float

Open
#1,979 0 comments 0 reactions 0 assignees View on GitHub

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 document with max/minContains removes constraint if value is a float
swagger-parser version: 2.1.1

For spec:

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:
    MaxcontainsWithContainsValueWithADecimal:
      $schema: https://json-schema.org/draft/2020-12/schema
      contains:
        const: 1
      maxContains: 1.0
    MincontainsWithContainsValueWithADecimal:
      $schema: https://json-schema.org/draft/2020-12/schema
      contains:
        const: 1
      minContains: 1.0

The parsed schema for MaxcontainsWithContainsValueWithADecimal has the value for maxContains set to null when it should be the value 1.0, a json number.
This prevents downstream users from being able to implement maxContains correctly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the supplied OpenAPI 3.1 document and trace how the Java parser handles maxContains and minContains when their values are written as 1.0. Done means both constraints remain present as the JSON number 1.0 in the parsed schema, with coverage for the reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.