Closed simon-spinner closed 2 years ago
@simon-spinner
Thanks for reporting the issue.
I havent been able to test it myself, but could you already share if this happens everywhere or only certain OAS elements (like schema or components)?
Since 1.9.1, we provided support for large numbers that were converted unwanted. It feels that this is a side-effect of that change.
@simon-spinner
I just updated an existing test, where the input/output are the same
components:
schemas:
Pet:
type: object
properties:
properties:
type: string
example: 123e4567-e89b-12d3-a456-426614174000
id:
type: integer
format: int64
example: 10
title:
type: string
example: 500.1
name:
type: string
example: 123456789012345678901234567890
I tried with the exact same numeric value "500.1". This is a comparison of the input (original value) & output (after openapi-format conversion)
Can you provide me with an example where the conversion is incorrect?
(I'm using openapi-format 1.9.2)
Slightly adapted your example:
openapi: 3.0.2
info:
title: Repro
version: '1.0'
paths: {}
components:
schemas:
Pet:
title: '500.1'
type: object
properties:
properties:
type: string
example: 123e4567-e89b-12d3-a456-426614174000
id:
type: integer
format: int64
example: 10
title:
type: string
example: 500.1
name:
type: string
example: 1.2345678901234568e+29
After formatting it is:
openapi: 3.0.2
info:
title: Repro
version: '1.0'
paths: {}
components:
schemas:
Pet:
title: 500.1
type: object
properties:
properties:
type: string
example: 123e4567-e89b-12d3-a456-426614174000
id:
type: integer
format: int64
example: 10
title:
type: string
example: 500.1
name:
type: string
example: 1.2345678901234568e+29
which is not valid according to OpenAPI json schema.
aha, now I see ! Indeed that is not desired behaviour.
I'll work on a bug fix
@simon-spinner I just merged a bugfix for this bug. It will be part of the upcoming release.
Closing the issue, since we just release 1.10.0 of openapi-format. If the issue would not be solved, feel free to reopen this item.
If the
title
attribute of a schema contains only a string that looks like a number, e.g.: "500.1", starting with 1.9.1 openapi-format will turn it into a number in the formatted output (yaml format). The resulting specification is illegal, as the title attribute must always be a string and not a number.