s-knibbs / dataclasses-jsonschema

JSON schema generation from dataclasses
MIT License
167 stars 38 forks source link

DataclassesPlugin fixed (for objects and for arrays). #132

Open ZdenekM opened 4 years ago

ZdenekM commented 4 years ago

My attempt to fix the issue #126. It works for objects as well as for arrays of objects. I also propose to change the way how the schema is referenced. Right now it is:

content:
  application/json:
    schema: Pet

while I think this would be more appropriate:

content:
  application/json:
    schema:
      $ref: Pet

This PR also adds support for arrays of objects so definitions like this can be used:

content:
  application/json:
    schema:
      type: array
      items:
        $ref: Pet

@s-knibbs Please let me know what you think about this fix and (hopefully) enhancement.

ZdenekM commented 4 years ago

@s-knibbs What do you think? If you are ok with the change, I will also update tests and README. It would be great if this PR can make it into release soon - one project I'm working on depends on this. Many thanks!