cebe / php-openapi

Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
MIT License
466 stars 88 forks source link

Allow passing prepared objects instead of array definition #28

Closed SilverFire closed 5 years ago

SilverFire commented 5 years ago

Before this pull request I was able to write only

new Server([ 
    'url' => "{protocol}://$host/",
    'variables' => [
        'protocol' => [
            'enum' => ['http', 'https'],
            'default' => 'https', 
        ],
    ],
])

It's could be enough, but when it comes to more complex code, I would like to write something like that to be more verbose on what is going on inside my object:

new Server([ 
    'url' => "{protocol}://$host/",
    'variables' => [
        'protocol' => new ServerVariable([
            'enum' => ['http', 'https'],
            'default' => 'https',
        ]),
    ],
])

This pull request enhances library so it respects the passed object.

SilverFire commented 5 years ago

Hi, Carsten! I've added a test that covers SpecBaseObject, Paths and PathItem behavior at once.

cebe commented 5 years ago

Merged, thank you!