-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Framework: add schema for posts #3487
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
export const itemsSchema = { | ||
type: 'object', | ||
patternProperties: { | ||
//be careful to escape regexes properly | ||
'^[0-9a-z]+$': { | ||
type: 'object', | ||
required: [ 'ID', 'site_ID', 'global_ID' ], | ||
properties: { | ||
ID: { type: 'integer' }, | ||
site_ID: { type: 'integer' }, | ||
global_ID: { type: 'string' }, | ||
author: { type: 'object' }, | ||
date: { type: 'string' }, | ||
modified: { type: 'string' }, | ||
title: { type: 'string' }, | ||
URL: { type: 'string' }, | ||
short_URL: { type: 'string' }, | ||
content: { type: 'string' }, | ||
excerpt: { type: 'string' }, | ||
slug: { type: 'string' }, | ||
guid: { type: 'string' }, | ||
status: { type: 'string' }, | ||
sticky: { type: 'boolean' }, | ||
password: { type: 'string' }, | ||
parent: { type: [ 'object', 'boolean' ] }, | ||
type: { type: 'string' }, | ||
discussion: { type: 'object' }, | ||
likes_enabled: { type: 'boolean' }, | ||
sharing_enabled: { type: 'boolean' }, | ||
like_count: { type: 'integer' }, | ||
i_like: { type: 'boolean' }, | ||
is_reblogged: { type: 'boolean' }, | ||
is_following: { type: 'boolean' }, | ||
featured_image: { type: 'string' }, | ||
post_thumbnail: { type: [ 'string', 'null' ] }, | ||
format: { type: 'string' }, | ||
geo: { type: 'boolean' }, | ||
menu_order: { type: 'integer' }, | ||
page_template: { type: 'string' }, | ||
publicize_URLS: { type: 'array' }, | ||
tags: { type: 'object' }, | ||
categories: { type: 'object' }, | ||
attachments: { type: 'object' }, | ||
attachment_count: { type: 'integer' }, | ||
metadata: { type: 'array' }, | ||
meta: { type: 'object' }, | ||
capabilities: { type: 'object' }, | ||
other_URLs: { type: 'object' } | ||
} | ||
} | ||
}, | ||
additionalProperties: false | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering, should we allow
additionalProperties
here? What if we wanted to add a property for some other client... that wouldn't necessarily get a lot of testing before the change hit the API because we've traditionally been pretty lax about adding properties to api responses. I can understand we don't want people to rely upon attributes outside of this schema... is there another way to enforce that without making it fail out when there's an extra attribute?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
additionalProperties
is by default true, and the post object itself allows extra props. This one here will not validate if it doesn't match the regex in patternProperties (a global post id like 3d097cb7c5473c169bba0eb8e3c6cb64).