Skip to content
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

Support for additional Open API features (deferred) #21

Open
4 tasks
AlexanderAllen opened this issue Apr 19, 2024 · 1 comment
Open
4 tasks

Support for additional Open API features (deferred) #21

AlexanderAllen opened this issue Apr 19, 2024 · 1 comment
Assignees

Comments

@AlexanderAllen
Copy link
Owner

AlexanderAllen commented Apr 19, 2024

This issue is an epic. If I decide to ship anything mentioned here, I will cut such feature into it's own separate ticket.

The features listed here are supported by the Open API spec, but are currently not implemented, nor I necessarily deem them urgent for my personal use cases.

Therefore I'm capturing these features in this ticket for future reference.

  • uniqueItems
  • additionalProperties
  • Required properties. Right now produced types are mostly nullable just to get the ball rolling. It would be nice to support required props across the board.
  • Multiple variations of mixed type arrays, such as those containing both object literals mixed in with scalar types and references. This becomes rabbit-holey, but I am noting nonetheless that either more tests could be created, and/or more runtime assertions could be put in place to blunt the impact of any potentially silly recursions. Generated types are typically one-dimensional, with unions and intersections adding some depth, but PHPStan could offer limitless virtual type variations in arrays. Not sure Panettone would be the right place for interpreting mixed arrays into array shapes as again, that's a can of worms waiting to be opened.

Not supporting

@AlexanderAllen AlexanderAllen self-assigned this Apr 19, 2024
@AlexanderAllen
Copy link
Owner Author

AlexanderAllen commented Apr 19, 2024

Moving some inline comments from the test to here for future reference, and to clamp down on the test file size.

    // ADV_ALLOF_EDGECASE
    // TooManyRequests:
    // allOf:
    //   - $ref: '#/components/schemas/Error'
    //   - $ref: '#/components/schemas/Error'
    //   - type: object
    //     properties:
    //       spam_warning_urn:
    //         type: string
    //       some_other_ref:
    //         $ref: '#/components/schemas/Error'

    /**
     * Test for schema with a Type of "allOf".
     *
     * # This ...
     * TooManyRequests:
     *   allOf:
     *     - $ref: '#/components/schemas/Error'
     *     - type: object
     *       properties:
     *         spam_warning_urn:
     *           type: string
     *
     * # Should translate to this ...
     *   Class TooManyRequests
     *     public readonly ?Error $error = null
     *     public ?string $spam_warning_urn = null
     *
     * Notes:
     *   - cebe interprets the first $ref as an object, complete with inline properties ready for use
     *     when using `RESOLVE_MODE_ALL`. Adding these props straight away would result in inlined props
     *     and therefore duplicate props between types!
     *   - Both the first $ref Schema item and the second 'anonymous' Schema item have a cebe
     *     Schema type of `object`. Keep an eye on the conditions on the prop generator
     *     to prevent these getting mixed up.
     *
     * @TODO Test more complex edge cases w/ multiple and nested references. See ADV_ALLOF_EDGECASE above.
     *
     * @see https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
     */

AlexanderAllen added a commit that referenced this issue Apr 20, 2024
AlexanderAllen added a commit that referenced this issue Apr 28, 2024
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant