grape-swagger icon indicating copy to clipboard operation
grape-swagger copied to clipboard

[WIP] Open api3 rebased

Open numbata opened this issue 1 year ago • 7 comments

This is rebased version of the branch oapi-3 from #744

Current state:

Finished in 11.31 seconds (files took 0.94256 seconds to load)
644 examples, 34 failures, 2 pending

numbata avatar May 08 '24 09:05 numbata

👀 Looking forward to this!

dblock avatar Jul 12 '24 12:07 dblock

Finished in 7.49 seconds (files took 0.9935 seconds to load)
644 examples, 34 failures, 2 pending, 76 errors occurred outside of examples

numbata avatar Jul 13 '24 08:07 numbata

Finished in 11.31 seconds (files took 0.94256 seconds to load)
644 examples, 34 failures, 2 pending

numbata avatar Jul 13 '24 08:07 numbata

Finished in 11.22 seconds (files took 0.93428 seconds to load)
644 examples, 52 failures, 2 pending

The reason for 📈 🔴 is: after alignment of the openapi3 schema builder with the openapi2, the request object goes under the $ref, some specs become red.

numbata avatar Jul 14 '24 21:07 numbata

Finished in 12.34 seconds (files took 1 second to load)
644 examples, 69 failures, 2 pending

📈 🔴 after the addition of validation against the OpenAPI3 specification.

numbata avatar Jul 14 '24 22:07 numbata

My intermediate thoughts and Suggestions:

First of all I would like to say that @blakepettersson has done a fantastic job. I really appreciate the effort, especially the specs, which make me confident about achieving OpenAPI3 schema from Grape endpoints.

However, while working on the branch, I felt that the chosen strategy might not be ideal. Copying the existing OpenAPI2 code and modifying it for OpenAPI3 resulted in two separate codebases doing almost the same job, making synchronization difficult.

In addition, the new DryValidation and DrySchema support for request parameter definition is not currently supported in the existing code. This could be a deterrent for potential users who may choose other frameworks if Grape lacks this feature.

But there's hope. I believe that we should separate the process of gathering endpoint information from the process of schema generation, possibly by using intermediate structures. These structures can be fully populated first, and then we can generate the specific OpenAPI version schema.

One possible implementation is to use DrySchemas as schema objects that can be translated from native Grape params. This approach offers the benefits of schema composition, which is a valuable feature in OpenAPI3 that is missing in OpenAPI2.

Overall, a more modular approach could make maintenance easier and support both OpenAPI2 and OpenAPI3 more effectively.

numbata avatar Jul 15 '24 10:07 numbata