openapi-changes icon indicating copy to clipboard operation
openapi-changes copied to clipboard

1e-8 and 1e-08 difference reported as a breaking change

Open qfreewilll opened this issue 5 months ago • 0 comments

When comparing OpenAPI specs that contain floating-point defaults like 1e-08, openapi-changes reports a change if the compared value is1e-8. This is a cosmetic difference only – both are numerically identical JSON values and should not be considered a change.

To Reproduce

Save the following as openapi1.json:

{
    "openapi": "3.0.0",
    "info": {
        "title": "Example",
        "version": "1.0.0"
    },
    "paths": {},
    "components": {
        "schemas": {
            "Config": {
                "type": "object",
                "properties": {
                    "angle_threshold": {
                        "type": "number",
                        "exclusiveMinimum": 0.0,
                        "title": "Angle Threshold",
                        "default": 1e-08
                    }
                }
            }
        }
    }
}

Save the following as openapi2.json:

{
    "openapi": "3.0.0",
    "info": {
        "title": "Example",
        "version": "1.0.0"
    },
    "paths": {},
    "components": {
        "schemas": {
            "Config": {
                "type": "object",
                "properties": {
                    "angle_threshold": {
                        "type": "number",
                        "exclusiveMinimum": 0.0,
                        "title": "Angle Threshold",
                        "default": 1e-8
                    }
                }
            }
        }
    }
}

Run

docker run -t -v .:/openapi pb33f/openapi-changes:latest summary --markdown --no-color /openapi/openapi1.json /openapi/openapi2.json
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

@@@@@@@   @@@@@@@   @@@@@@   @@@@@@   @@@@@@@@
@@@@@@@@  @@@@@@@@  @@@@@@@  @@@@@@@  @@@@@@@@
@@!  @@@  @@!  @@@      @@@      @@@  @@!
!@!  @!@  !@   @!@      @!@      @!@  !@!
@!@@!@!   @!@!@!@   @!@!!@   @!@!!@   @!!!:!
!!@!!!    !!!@!!!!  !!@!@!   !!@!@!   !!!!!:
!!:       !!:  !!!      !!:      !!:  !!:
:!:       :!:  !:!      :!:      :!:  :!:
 ::        :: ::::  :: ::::  :: ::::   ::
 :        :: : ::    : : :    : : :    :


🔗 https://pb33f.io/openapi-changes/
------------------------------------
openapi-changes version: latest | compiled: Wed, 04 Jun 2025 10:20:45 UTC


└─┬Components
  └─┬Config
    └─┬angle_threshold
      └──[🔀] default (17:36)❌


| Document Element | Total Changes | Breaking Changes |
|------------------|---------------|------------------|
| components       | 1             | 1                |

Date: 06/04/25 | Commit: Original: /openapi/openapi1.json, Modified: /openapi/openapi2.json,

- ❌ **BREAKING Changes**: _1_ out of _1_
- **Modifications**: _1_
- **Breaking Modifications**: _1_

Expected behavior No change should be reported – 1e-08 and 1e-8 are equivalent in JSON and OpenAPI.

qfreewilll avatar Jun 04 '25 11:06 qfreewilll