oooas
oooas copied to clipboard
Add parse ability
Need to provide a way to take a PHP array, or JSON string and convert it into an OpenApi
instance (with child objects created).
Should also be able to create any object from JSON, e.g. add a Schema
from a JSON string (no need to parse an entire spec).
Todo
- [ ] Provide abstract
parse()
method onBaseObject
class - silently ignores any errors (missing/extra properties) - [ ] Provide abstract
strictParse()
method onBaseObject
class - throws exception for any errors - [ ] Each object to define their own
parse()/strictParse()
implementation - [ ] Each implementation to handle the creation of child/nested objects
Wish I had the time to work on this. A related thing I would really like would be the ability to take a json schema for a property from an external source and inject it (with any required modifications).
Hey @baohx2000 👋
I don't fully understand - what's the use case for your suggestion? 🙂
I generate api documentation using this library by iterating through annotations in code. The annotations also define input parameter validation using various rules, one of which is using a json schema for complex values. What I'd like to do is include the schema as part of the openapi doc that gets generated from this library. Just figured parsing json into the library would be a good first step.
@baohx2000 So is the idea to parse JSON not only for the entire spec, but to append to an existing one? Sounds like a great idea. I'll update the issue to include.