oooas icon indicating copy to clipboard operation
oooas copied to clipboard

Add parse ability

Open matthew-inamdar opened this issue 5 years ago • 4 comments

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 on BaseObject class - silently ignores any errors (missing/extra properties)
  • [ ] Provide abstract strictParse() method on BaseObject 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

matthew-inamdar avatar May 18 '19 09:05 matthew-inamdar

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).

baohx2000 avatar Oct 28 '20 20:10 baohx2000

Hey @baohx2000 👋

I don't fully understand - what's the use case for your suggestion? 🙂

matthew-inamdar avatar Oct 28 '20 21:10 matthew-inamdar

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 avatar Oct 28 '20 21:10 baohx2000

@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.

matthew-inamdar avatar Oct 28 '20 22:10 matthew-inamdar