api-platform / api-platform/api-doc-parser

Ability to cache for offline usage

Open
#43 1 comment 0 reactions 0 assignees View on GitHub
Hacktoberfest
Dominant language
TypeScript
Stars
113
Forks
80
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'd like to be able to initialize the API specs from an existing cache in order to get the most recently known state of the api docs in case of offline usage.

Basically I need to be able to serialize the specs into JSON and deserialize from JSON. As far as I can see the tests currently utilize `JSON.stringify()` already which is nice but in my case I'm getting issues with an API spec which has circular references internally (e.g. a `Resource` is referencing another `Resource` its `Field.reference` property).

As the `parseHydraDocumentation` is capable of creating those references properly based on the api docs I'm currently thinking that utilizing the collected response(s) for caching and instantiate a new instance of `Api` with its belongings from that state.

If I see it correctly it should be sufficient to separate the "fetch" and "parse" capabilities that are currently handled implicitly in the `parseHydraDocumentation` - like having one separately exported function that does only the parsing which is currently done here:

https://github.com/api-platform/api-doc-parser/blob/a9e097339ecd88b0515238c49e504ff17edcc1c3/src/hydra/parseHydraDocumentation.js#L196-L442

I could try to come up with a PR for this but I'd like to get some opinions on that first.

Best

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.