AlexanderAllen / panettone

A lightweight PHP type generator for Open API (formerly Swagger)
GNU General Public License v3.0
1 stars 0 forks source link

Use functional patterns when parsing Open API source #58

Open AlexanderAllen opened 1 month ago

AlexanderAllen commented 1 month ago

Panettone is currently not powerful enough to infer and generate the type information for array items, and probably more advanced OpenAPI use cases (read: very nested structures).

Therefore when an array type is encountered in the OAS spec the generated value objects for PHP simply contain an array() as the type. This means you don't know what kind of information is contained in the array. This is the kind of challenge I set out to work on with this project.

I am trying to see if by incorporating FantasyLand (functional) patterns I can grant the parsing logic in Panettone the power to output more type-complete value objects.

All the action is happening in the test/Unit space.

From the July 2024 roadmap

AlexanderAllen commented 1 month ago

💥 July 11, 2024: Some of the generics in the fantasy spec are borked and won't compile. Instead of overriding their interfaces in my code to fix them, I'll may just do it directly at the sauce 🌶️.

AlexanderAllen commented 1 month ago

7/2 - Marrying the Fantasy Semigroup interface to my Monoid @ test/Unit/Monoids/LawsTest.php

Both Semigroup and Monoid implement concat. And a monoid is a semigroup with an identity element.

The book's implementation is static while fantasy land is not, so I had to spend some time converting the current static Monoid to a non-static implementation.

The book has priority for laws, but fantasy land has priority for the public interfaces.