Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Add types or interfaces describing REST API responses #9

Closed
Shelob9 opened this issue May 27, 2020 · 2 comments
Closed

Add types or interfaces describing REST API responses #9

Shelob9 opened this issue May 27, 2020 · 2 comments

Comments

@Shelob9
Copy link

Shelob9 commented May 27, 2020

@johnbillion I wanted to continue this discussion: WP-API/node-wpapi#149 (comment) I'm sorry for the delayed response. Life happened.

I found the types I had started:

It's challenging, beacuse the WordPress REST API is so extensible. The node-wpapi generates dynamic schemas, per site, which is cool. I am not sure how to provide a "standard" defintion of something that can be different on any site.

@johnbillion
Copy link
Owner

Thanks Josh, that's a good start.

I changed this library a few days ago so its interfaces are all generated from wp-json-schemas, so if the default schemas in an OPTIONS request to the REST API are correct (ie. with additionalProperties set to true) then we should be okay. Or we can tweak the TS interfaces accordingly so they fit the default schema for a vanilla site.

@johnbillion
Copy link
Owner

johnbillion commented Nov 27, 2020

I've added definitions for posts and users in b958d04. Like the rest of this library, these are generated from wp-json-schemas and are based only on the default endpoints on a vanilla site.

For now, most property definitions are part of the main User or Post object, but I think splitting them out like you did in your definitions has value.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants