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

Empty SecurityRequirement in YAML file #46

Closed NukeBoy closed 4 years ago

NukeBoy commented 4 years ago

When trying to write a Security Requirement object to a YAML file: $openapi->security = [new SecurityRequirement(['Bearer' => []])]; The result is:

security:
        -
          Bearer: {  }

When expected:

security:
        -
          Bearer: []

When writing to a JSON file, everything is fine:

"security": [
    {
         "Bearer": []
    }
]
cebe commented 4 years ago

seems symfony/yaml is interpreting this wrong... not sure how to solve it, if it would print an array intead of object we could just pass a stdClass object, but I don't know a way to force the type the other way round...

coatesap commented 4 years ago

Potential fix for this suggested in #52