biocad / openapi3

OpenAPI 3.0 data model
BSD 3-Clause "New" or "Revised" License
39 stars 53 forks source link

Exception when parsing newer OpenApi3 schemas #64

Closed tonicebrian closed 1 year ago

tonicebrian commented 2 years ago

When parsing OpenApi 3.0.2 schemas like the Pet Store api with:

eitherDecodeFileStrict openApiFile :: IO (Either String OpenApi)

I get an exception:

"Error in $: Additonal field don't match for key openapi: String "3.0.0" /= String "3.0.2""

This is so because in https://github.com/biocad/openapi3/blob/master/src/Data/OpenApi/Internal/AesonUtils.hs#L199-L205 the check is testing for equality on the version defined in https://github.com/biocad/openapi3/blob/master/src/Data/OpenApi/Internal.hs#L1595, so newer versions like latest 3.0.3 will fail when reading.

I thought on submitting a PR where we check for a regular expression instead of hard equality but I don't know about implications. Is this the way to go or would you approach the resolution differently?

maksbotan commented 2 years ago

Well, this library is based on 3.0.0 spec. If we were to support newer versions, I'd have to review them for potential differences.

Are you sure that the spec is at least backwards-compatible?

tonicebrian commented 2 years ago

Yes I think it is backwards compatible.

Also they bumped the patch version in the semver so theoretically it should be backwards compatible.

maksbotan commented 2 years ago

Ah, so the changes are only to the spec text, not to semantics?

Could you make a PR allowing all 3.0.x versions then?

tonicebrian commented 2 years ago

Hey @maksbotan did you have a look at the PR? Is it OK for you?