OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

Warning 'Data and type mismatch found.' with 'date-time' format

Open adsk-duszykf opened this issue 1 year ago • 5 comments

I get a warning: 'Data and type mismatch found.' with this response description:

DiffCreatedEvent:
  description: 'diff index created
  type: object
  additionalProperties: false
  properties:
    updatedAt:        { $ref: '#/components/schemas/Timestamp' }
  example:
    {
      "updatedAt": '2020-06-30T06:43:51.391Z',
    }
Timestamp:      { type: string, format: date-time, description: 'timestamp', example: '2020-06-30T06:43:51.391Z' }

but no warning with this:

DiffCreatedEvent:
  description: 'diff index created
  type: object
  additionalProperties: false
  properties:
    updatedAt:        { type: string, format: date-time, description: 'timestamp', example: '2020-06-30T06:43:51.391Z' }
  example:
    {
      "updatedAt": '2020-06-30T06:43:51.391Z',
    }

adsk-duszykf avatar Apr 25 '24 08:04 adsk-duszykf

Thanks for raising this @adsk-duszykf

The warning seems to be raised by the OpenApi.Net library as it parses the description at https://github.com/microsoft/OpenAPI.NET/blob/29b1a1a9acbc65d7b2961b3f08e681a1e59d7c38/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs#L42C28-L42C52

Any chance you can post the issue at the https://github.com/microsoft/openAPI.NET repo for the team to investigate? @MaggieKimani1

andrueastman avatar Apr 25 '24 09:04 andrueastman

Or we can simply transfer the issue @andrueastman ;)

baywet avatar Apr 25 '24 13:04 baywet

Or we can simply transfer the issue @andrueastman ;)

Much more efficient

andrueastman avatar Apr 25 '24 15:04 andrueastman

Unfortunately we are very aware of this issue and are working hard to make the problem go away in v2. There are a range of issues with the way this particular validation works today and we have never found a good way of fixing it that didn't involve just ripping all the datatype mismatch errors out. The good news is that in V2 it will actually do proper, full JSON Schema validation of the examples.

darrelmiller avatar Apr 26 '24 17:04 darrelmiller

@darrelmiller thank you !

adsk-duszykf avatar Apr 26 '24 18:04 adsk-duszykf

@MaggieKimani1 Let us validate if it is fixed in v2 and then close.

RachitMalik12 avatar Feb 27 '25 16:02 RachitMalik12