api-doc-parser icon indicating copy to clipboard operation
api-doc-parser copied to clipboard

WIP: Serialization handling for cacheability

Open olivermack opened this issue 6 years ago • 6 comments

This is for #43

This adds an ApiSerializer which converts to a json-serializable POJO in both directions. Please let me know if this approach conflicts with any best practices or design considerations of this lib.

Best

olivermack avatar Jan 17 '19 16:01 olivermack

Can anyone help me to get the idea here? I'm not that much into flow and I'm just curious about the linter errors: obviously the linter requires to specify the readable properties in the class definition - but most of the classes here do not really have those property definitions; instead, the properties are defined on runtime via Object.defineProperty() ... that basically means that the properties in fact may - or may not - exist, depending on the runtime circumstances and thus they cannot be checked statically...

In the serializer of this PR I make use of the three dots for rest and spread... Basically for one reason: I only want to extract those parameters from the objects where the serializer needs to perform special actions - by this I was hoping to keep the stuff as flexible as possible when in comes to changes of the properties of the objects.

Any hints? I mean, why is then using flow at the end when the values are set magically in the object's constructors anyway? Why not setting those typed options containers as an member as is?

type ApiOptions = {
  title?: string,
  // ...
};

export default class Api {
  entrypoint: string;
  options: ApiOptions;

  constructor(entrypoint: string, options: ApiOptions = {}) {
    this.entrypoint = entrypoint;
    this.options = options;
  }
}

olivermack avatar Jan 17 '19 17:01 olivermack

Can you also check why the tests are failing please? It looks related to this change.

dunglas avatar Jan 28 '19 09:01 dunglas

@dunglas thanks for checking. It's actually not the tests themselves that fail (as far as I can assess) it's the linter that struggles because I'm spreading member variables from the api-objects which are dynamically declared... this is actually what my last comment was about.

olivermack avatar Jan 28 '19 09:01 olivermack

Hey... any news? I still need to know how to proceed here.

olivermack avatar Feb 18 '19 09:02 olivermack

Sorry for the lack of response. We’ll try to review ASAP. Having Travis green is mandatory.

dunglas avatar Feb 18 '19 09:02 dunglas

Having Travis green is mandatory

Yah, sure, no question... This is what my initial question was about which I cannot solve on my own...

olivermack avatar Feb 18 '19 09:02 olivermack