cog icon indicating copy to clipboard operation
cog copied to clipboard

Switch kin-openapi to libopenapi

Open yorickvP opened this issue 1 year ago • 10 comments

Required for #1482, #1186, #1216

yorickvP avatar Feb 19 '24 17:02 yorickvP

Sadly, libopenapi doesn't discover the invalidness of https://github.com/replicate/cog/blob/main/test-integration/test_integration/fixtures/invalid-int-project/predict.py

yorickvP avatar Feb 19 '24 19:02 yorickvP

https://github.com/pb33f/libopenapi-validator/issues/53

yorickvP avatar Feb 19 '24 19:02 yorickvP

I think it's okay to delete that test case. It's a pretty rare case, and wouldn't be hard to upstream a change to libopenapi to handle that case.

andreasjansson avatar Apr 13 '24 11:04 andreasjansson

@yorickvP could you describe in a bit more depth why we need to switch to libopenapi? It's not obvious to me.

andreasjansson avatar Apr 13 '24 11:04 andreasjansson

This comment contains a summary: https://github.com/replicate/cog/issues/1186#issuecomment-2011832395

We could try to get away with kin-openapi, that would just require fixing the test for the version in https://github.com/replicate/cog/pull/1552

yorickvP avatar Apr 15 '24 14:04 yorickvP

cc @nickstenning who's got a fair bit of experience working with kin-openapi

zeke avatar May 06 '24 18:05 zeke

We use kin-openapi in the api repository to process the schemas generated by cog models, and I would probably want to see us using the same code both here and in production.

What is actually wrong with kin-openapi?

nickstenning avatar May 06 '24 18:05 nickstenning

What is actually wrong with kin-openapi?

No OpenAPI v3.1 support: https://github.com/getkin/kin-openapi/issues/230#issuecomment-1002659224

However, it seems we happen not to use any of the unsupported 3.1 features. Would be good to check somehow.

yorickvP avatar May 07 '24 09:05 yorickvP

Our own API's spec is 3.1, and we use kin-openapi to validate it in the api codebase. Is the lack of official 3.1 support actually causing us any problems?

nickstenning avatar May 07 '24 09:05 nickstenning

Here's a list of changes: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0 . My concern here is that these schemas are generated from user input by pedantic, so we don't necessarily control it when they break. The thing we should mainly test is exclusiveMinimum (pydantic's gte).

yorickvP avatar May 07 '24 09:05 yorickvP

Closing in favor of #1687, which rewrites the OpenAPI 3.1 spec version emitted by FastAPI to OpenAPI 3.0.

mattt avatar Jun 24 '24 13:06 mattt