jsonschema2md icon indicating copy to clipboard operation
jsonschema2md copied to clipboard

Unable to resolve locally available schemas

Open huksley opened this issue 6 years ago • 2 comments

What did you do

I've taken this project: https://github.com/maasglobal/maas-schemas

And I trying to generate documentation by running

npm install @adobe/jsonschema2md
yarn jsonschema2md -d schemas -e json -e o docs

What did you expect to happen

  • [x] All schema documentation generated in docs
  • [ ] All internal links resolved properly

What happened

  • All schema documentation generated in docs
  • No links resolved between schemas
  • Lots of warnings during generation, such as
unresolved reference: http://maasglobal.com/maas-backend/customers/payment-sources/paymentSource.json#/definitions/type
unresolved reference: #/definitions/acceptHeader

What's your environment

  • Operating System: Mac OS X 10.14.6
  • node.js version: 12.11.1
  • jsonschema2md version 3.3.1

Do you have example files:

Schemas in schemas/ folder

https://github.com/maasglobal/maas-schemas

Markdown examples

Excerpt from core README.md

## /tsp/booking-create/

- [](./tsp/booking-create/request.md) – `http://maasglobal.com/tsp/bookings-create/request.json` (Unknown)
- [](./tsp/booking-create/response.md) – `http://maasglobal.com/tsp/bookings-create/response.json` (Unknown)

Excerpt from core/booking-option.md

...
## agencyId

`agencyId`

- is optional
- type: reference
- defined in this schema

### agencyId Type

- []() – `http://maasglobal.com/core/components/common.json#/definitions/agencyId`

...

huksley avatar Nov 05 '19 08:11 huksley

As far as I understood code for jsonschema2md it tries to prepare $linkVal, $linkRef properties for all schema objects which are $ref from all available in schemaMap and AJV schemas recursively.

However, AFAIK, this code is not working properly/disabled? in recent version of jsonschema2md. (Schema..resolveRef are never called in https://github.com/adobe/jsonschema2md/blob/master/lib/schema.js )

So I went ahead and created my version of this recursive walking https://github.com/huksley/maas-schemas/blob/make-docs/utils/make-docs.js

It works better https://huksley.github.io/maas-schemas/docs/ but it would be great to have this code working again so I don't need to do it manually.

Alos, invoking it as a package breaks without initializing i18n global instance with locales. Is there any way of doing it in a better way?

huksley avatar Nov 05 '19 08:11 huksley

I've been experiencing this since about a year ago, which is why I never implemented this. Would be great to have this working.

dskvr avatar Jan 11 '20 18:01 dskvr