question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swagger validation which was working fine on 12th Feb is now failing validation for type: string, when it contains an example date as value

See original GitHub issue

Example Swagger/OpenAPI definition:


                    "DateOfDelivery": {
                      "example": "2019-09-26",
                      "type": "string"
                    },

Describe the bug you’re encountering

The above is part of my swagger spec, and is getting validated ok in editor.swagger.io

We have release pipelines configured. The task ‘API Management - Create or Update API’ is used in the azure devops portal to configure the web api. The task’s field ‘Definition Artifact’ is given the path of the swagger spec file.

The pipeline was running OK since November 2019 until around 12th Feb 2020. Since around 13th Feb we started to get validation errors when the pipeline runs.

Error:

2020-02-14T12:21:06.8150207Z Data and type mismatch found. [#/paths/~1order-product/post/responses/200/content/application~1json/schema/properties/DateOfDelivery/example]
@{code=ValidationError; target=representation; message=Parsing error(s): The input OpenAPI file is not valid for the OpenAPI specification https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md (schema https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v3.0/schema.yaml).}

Expected behavior

No errors

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nachiketrsscommented, Feb 19, 2020

@VitaliyKurokhtin - can you give me more detail as to what caused the issue and how/when it got resolved please.

1reaction
michaeltnguyencommented, Feb 17, 2020

Hi, this is related to https://github.com/Azure/api-management-developer-portal/issues/294. We had the same problem with date-only examples like you have. The workaround is to have the type be a “date-time”. (this is wrong, but will allow your API to be imported).

The underlying bug is in Microsoft’s implementation of OpenApi reader, which has gone unfixed for a very long time.

microsoft/OpenAPI.NET#407 microsoft/OpenAPI.NET#420 <-- specifically about dates https://github.com/microsoft/OpenAPI.NET/issues/429

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger validation which was working fine on 12th Feb is ...
Swagger validation which was working fine on 12th Feb is now failing validation for type: string, when it contains an example date as...
Read more >
Swagger schema validation failed
trying to import a URL and got this error: ``` Swagger schema validation failed. ... Expected type array but found type object at ......
Read more >
minLength/maxLength string tests assume the property is ...
This is an error in the validator because a minLength should not imply that the property is required; it indicates the minimum length...
Read more >
Correctly determine if date string is a valid date in that format
I am currently using a regex to validate the string format, which works ok, but I can see some cases where it could...
Read more >
API reference - Tink Docs
Welcome to the Tink API reference! The reference provides a detailed explanation of all resources that are accessible through the Tink API.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found