specref icon indicating copy to clipboard operation
specref copied to clipboard

Define TypeScript schema for responses

Open marcoscaceres opened this issue 2 years ago • 6 comments

It be nice to have a TypeScript types file, for APIs that consume this.

(I've not had a chance to do something like this before, but would be useful for projects like ReSpec that consume this data)

CC'ing @saschanaz who may provide guidance? 🙏

I think what we need is described in: https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html

marcoscaceres avatar Aug 19 '21 01:08 marcoscaceres

I haven't seen a type scheme defined without an actual library. Might be interesting to see an existing case.

saschanaz avatar Aug 19 '21 22:08 saschanaz

I'm thinking of something like: https://www.npmjs.com/package/@types/pluralize

Where the types are delivered independently of the actual library.

I guess then also specref itself would also use them - though it's not really a library in the traditional sense.

marcoscaceres avatar Aug 21 '21 00:08 marcoscaceres

That corresponds to the actual library named pluralize. Anyway there is @types/node which is obviously not a library and also @types/web-ie11, so probably doable.

saschanaz avatar Sep 17 '21 18:09 saschanaz

BTW I think getting a JSON schema file would probably be better for multiple language support 👀

saschanaz avatar Sep 17 '21 18:09 saschanaz

Like these?

tobie avatar Sep 17 '21 20:09 tobie

Oh cool. Maybe use things like https://www.npmjs.com/package/json-schema-to-typescript to generate TypeScript lib then?

saschanaz avatar Sep 17 '21 20:09 saschanaz