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

Allow SchemaCompositions to be added as property #50

Open
captnCC opened this issue Jul 18, 2021 · 2 comments
Open

Allow SchemaCompositions to be added as property #50

captnCC opened this issue Jul 18, 2021 · 2 comments

Comments

@captnCC
Copy link

captnCC commented Jul 18, 2021

Hi,
SchemaCompositions can be used on objects that have a schema property, but it is not possible to use them as a property in another Schema. The OpenApi Spec itself supports this usage.

@randelsr-vault
Copy link

randelsr-vault commented Mar 3, 2022

This. We should be able to use AllOf to help compose schemas.

I hacked into this with a fork. Wasn't sure if this is entirely correct otherwise it would be a PR:

goldspecdigital\oooas\src\Objects\Schemas.php

    /**
     * @param Schema|SchemaComposition ...$properties
     * @return static
     */
    public function properties(Schema|SchemaComposition ...$properties): self
    {
        $instance = clone $this;

        $instance->properties = $properties ?: null;

        return $instance;
    }

Seems the correct implementation would be to leverage \GoldSpecDigital\ObjectOrientedOAS\Contracts\SchemaContract but while that works, it doesn't seem to be fully implemented yet?

@matthew-inamdar
Copy link
Member

matthew-inamdar commented Mar 21, 2022

I'll look at implementing this in the next major release where we can leverage union types.

Edit: As we'll be dropping 7.x support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants