-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple use case for enum
#20
Comments
* Keyword `not` completed in #5 * Capture additional todos and requirements in #20, #21. * Captured comment in #21. * Note todo for test case allOf, issue #19. * Make TODOs for #15, #22, #23 in the code. * Tag #15 re: anyOf. * Issue #18: Initial boilerplate for file printer. * Update PanDeAgua boilerplate. * Promote all MediaNoche code except typematcher function. * Set Setup as a shared fixture in SRC :/ Sadly, can't seem to be able to leave this fixture under tests. PHPUnit does not see the namespaced class import, probably due to PHPUnit autoloading. * OMG: Wrong namespace ! I have been using \Test instead of \Tests all this time? composer.json autload is the source of thruth here. * Move all schemas from fixture to schema dir. * Demote Setup from src to tests where it belongs. * Make test namespace singular in composer autoload. * Make test directory consistent with namespace. * Git ignore only current schema path, but not sub paths. * Changed tests directory to singular test. * Update test path for PHPStan. * Initial print file implementation. * Disable namespace resolution and specify output directory. * Promote file printer to class. * Initial pan de agua comments. * Assert output file contains source class. * Swap out default printer for PSR printer. * Let the user decide both on nullable and readonly attributes. * Only set default value if present in source schema. * Address illegal characters for PHP symbols. * Cleanup some namespaces. * Update test paths on media noche. * Change test target to public file. * Update test path on Github Actions. * Create tmp output dir on github pipeline. * Create tmp output dir on github pipeline.
Removed from alpha, might be slightly bigger change that I want right now. |
Some inspiration pasta while I work on this:
From @handrews comment at issue 1900 (Apr, 2021):
So if Expanding on that:
Would equal
And as it concerns to OAS you really need both
Which in plain-English OAS would mean a string that allows a Q: Cool beans. But do PHP enums allow nulls? A: No (RFC). Only string and int are allowed in backed enums. A PHP enum case can be named "null", but that's not a literal Technically legal, but against the spirit of the law (objection!) : I'm fine with interpreting the type as a nullable something, the value however when it comes to enums is still sticky. Without further internal or external interpretation of the enum (with enum method, or external Interpreting that |
The folks at myclabs/php-enum had some thoughts about this a long time ago, way before PHP enums were released... |
I just noted this in test/schema/keyword-enum-simple.yml:
And that is making for a super interesting/fun problem to entertain in the code ( With "regular" object schemas a property generator only needs to concern itself with chugging out property types, confident that referenced "class types (objects)" will eventually find themselves in the pipeline and be generated as well. Assuming referenced objects were declared in component/schemas, and with OAS enforcing references. Enums and inline objects (without their own component/schema entry) then are kinda homeless and need a side action to define a stand-alone type for them. A property generator is a good place to detect their existence, since you are checking each schema's properties. But a property generator returns properties, not object-like structures, and that's where this gets interesting. For example, see this The generator is flawless in it's ability to generate both the stand-alone However a prospective caller to a property generator expects only properties in returns, what's up with that random enum object hanging in the response?! |
Final resolution for the meme solo debate up top:
|
FWIW, while I don't know PHP well at all, |
I think that
enum
is a pretty popular feature within the OpenAPI spec, and as such an initial release should support it, at least in the most basic form possible.At the very least scalar types should be supported in the enum, and if it's not unreasonable on time also nullable enums.
The text was updated successfully, but these errors were encountered: