joffrey-bion / livedoc

A not-so-annotation-based documentation generator for REST and websocket services
MIT License
5 stars 2 forks source link

TypeError: Cannot read property 'sections' of null #87

Closed ST-DDT closed 6 years ago

ST-DDT commented 6 years ago

When I use livedoc-ui-webjar v4.3.1 as the UI for the docs the page remains empty and an error is shown in the console. The jsondoc's json was generated with 4.3.1 as well.

http://localhost/livedoc/?url=http://localhost/myApp/jsondoc#/global

Firefox:

firefox

Chrome:

Chrome

I cannot give you the json for the doc that causes this, but if you can pinpoint it to a small section I could try to anonymize and upload it.

I tried searching for sections in the json, but I could not find it. Do you have a non-obfuscated/non-minimized version of the UI or a .map file so I could give you some more hints?

ST-DDT commented 6 years ago

Assumption:

const hasGeneral = globalDoc.sections.length > 0;

Fails because the related values in the json are null/missing:

    [...]
    "flows": [],
    "global": null, // <-- here
    "playgroundEnabled": true,
    "displayMethodAs": "URI"
}
joffrey-bion commented 6 years ago

Good spot, it looks like I hadn't anticipated an absent global doc. One quick workaround for you would be to declare a global documentation as done in the sample app: https://github.com/joffrey-bion/livedoc/blob/master/sample-app/src/main/java/org/example/shelf/documentation/global/GlobalDocumentation.java

I'll have a look and try to quickly fix this issue.

What do you think would be best?

  1. disable the global doc tab in this case, and lead directly to the APIs tab
  2. create a generic default global doc page
ST-DDT commented 6 years ago

Currently your example app seems to be offline.

Well I guess there is slightly more to it.

No explicit global pages, but changelogs/migrations information.

In this case a generated general page would be useful however I'm not sure what should be shown there.

Neither global pages, nor changelogs, nore migrations

Having a proper landing page would be nice, but only if there is useful content in there.

Example generated global page

About this documentation

This documentation (v1.0.0) was generated for

  • MyApplication v1.4.2_20180410122345
    • org.example.controller
    • org.example.flows
  • MyDataPachage v1.4.0-Final
    • org.example.dto
    • org.example.enums

This page was automatically generated by livedoc v4.3.1 Refer to the livedoc documention on how to customize this view.

Template

About this documentation

This documentation (v${Version as passed to JsondocController}) was generated for

Multimap<String, String> applicationParts = packagesToScan.stream()
              .map(Util::toJavaPackage)
              .collectToMultimap(p -> p.getImplementationTitle() + " v" + p.getImplementationVersion(),
                                             p-> p.getName());

${foreach part in applicationParts}

  • ${part.title} ${foreach pack in part.packages}
    • ${pack.name}

This page was automatically generated by livedoc v${livedoc-core-version} Refer to the livedoc documention on how to customize this view.

joffrey-bion commented 6 years ago

Currently your example app seems to be offline.

Using the link in the README of the repo, the example app seems to run fine. Please open a separate issue with details if you have further problems (note the 8080 port btw).

Yes that's approximately what I had in mind regarding the default page. I guess a default would also be nice when there is just migrations and/or changelogs available, even if the issue does not occur in this case.

ST-DDT commented 6 years ago

Example is up and running. Looks like it is an firewall issue on my side.

joffrey-bion commented 6 years ago

A quick fix is now released for this issue in version 4.3.2, so that the UI does not crash. The other elements mentioned in this thread are tracked via https://github.com/joffrey-bion/livedoc/issues/90 and https://github.com/joffrey-bion/livedoc/issues/91.

ST-DDT commented 6 years ago

The fix works as expected. Thanks.