asyncapi-archived-repos / docgen

AsyncAPI documentation generator. DEPRECATED in favour of
https://github.com/asyncapi/generator
Apache License 2.0
21 stars 11 forks source link

Required fields in SchemaObject are rendered incorrectly #27

Closed fuzza closed 6 years ago

fuzza commented 6 years ago

It seems that there is an issue with rendering of required properties of SchemaObject. E.g. for a following API schema first_field of testSchema won't be rendered as a required.

asyncapi: "1.1.0"
info:
  title: Required fields issue demo
  version: "0.0.1"

topics:
  test:
    publish:
      $ref: "#/components/messages/testMessage"

components:
  messages:
    testMessage:
      summary: Testing
      payload:
        $ref: "#/components/schemas/testSchema"

  schemas:
    testSchema:
      type: object
      required:
        - first_field
      properties:
        first_field:
          type: string
        second_field:
          type: string
screen shot 2018-06-21 at 4 08 06 pm

From what I see inschema-prop template, there is a check of required array existance inside the prop object while it needs to check that parent schema object has propName in required array.

I have WIP fix for this issue in a forked repo, so please let me know if you want me to submit a PR. Looking forward for you feedback.

fmvilas commented 6 years ago

Hi @fuzza. Thanks for reporting. Absolutely, your PR is more than welcome!

NicoHood commented 6 years ago

Was this fix already pushed to the online editor? I saw similar problems. If yes, please update if no there are still problems.

fmvilas commented 6 years ago
screen shot 2018-07-21 at 19 36 42

@NicoHood @fuzza it's already working on the Editor. I also published the fix to npm (version 1.10.2): https://www.npmjs.com/package/asyncapi-docgen.

Thanks for the PR @fuzza!