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

Add a way to create schemas #159

Open
Herrick19 opened this issue Mar 16, 2022 · 1 comment
Open

Add a way to create schemas #159

Herrick19 opened this issue Mar 16, 2022 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@Herrick19
Copy link

Hi,

The library allows to create paths, but apparently doesn't provide any way to add schemas.

Doing something like:
$objOpenapi->components->schemas['foo'] = new Schema([ 'type' => Type::INTEGER, ]);

gives a warning and the element is not created:
PHP Notice: Indirect modification of overloaded property cebe\openapi\spec\Components::$schemas has no effect in G:\test.php on line 119

Am I missing something ?

If not, it would be nice if we could create dynamically elements using this library.

Thank in advance

@cebe cebe added the enhancement New feature or request label Apr 20, 2022
@cebe
Copy link
Owner

cebe commented Apr 20, 2022

You can currently do it like this:

$schemas = []; // or $schemas = $objOpenapi->components->schemas;

$schemas['foo'] = new Schema([ 'type' => Type::INTEGER, ]);
// add more here ...

$objOpenapi->components->schemas = $schemas;

This library was initally created to only read OpenAPI files, writing was added later so the programming API is not optimal.

@cebe cebe added this to the 2.0 milestone Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants