swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
774 stars 526 forks source link

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

Open spacether opened 10 months ago

spacether commented 10 months ago

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.