-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a schema for the REST API application passwords endpoint. Fixes #21.
- Loading branch information
1 parent
3dc25bc
commit ad1e60d
Showing
10 changed files
with
161 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,8 @@ | |
"wp core multisite-install --url=example.org --title=Example --admin_user=admin [email protected] --skip-email", | ||
"wp language core install de_DE it_IT ar he_IL", | ||
"wp json-dump routes", | ||
"wp json-dump application-password", | ||
"npm run test-rest-api-application-passwords", | ||
"wp json-dump settings", | ||
"npm run test-rest-api-settings", | ||
"wp json-dump rendered-block", | ||
|
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
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
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,72 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/hyper-schema#", | ||
"$id": "https://raw.githubusercontent.com/johnbillion/wp-json-schemas/trunk/schemas/rest-api/application-password.json", | ||
"title": "WP_REST_API_Application_Password", | ||
"description": "A user application password in a REST API context.", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": [ | ||
"uuid", | ||
"app_id", | ||
"name", | ||
"created", | ||
"last_used", | ||
"last_ip" | ||
], | ||
"properties": { | ||
"uuid": { | ||
"description": "The unique identifier for the application password.", | ||
"type": "string", | ||
"format": "uuid", | ||
"readOnly": true | ||
}, | ||
"app_id": { | ||
"description": "A UUID provided by the application to uniquely identify it. It is recommended to use an UUID v5 with the URL or DNS namespace.", | ||
"type": "string" | ||
}, | ||
"name": { | ||
"description": "The name of the application password.", | ||
"type": "string", | ||
"minLength": 1, | ||
"pattern": ".*\\S.*" | ||
}, | ||
"password": { | ||
"description": "The generated password. Only available after adding an application.", | ||
"type": "string", | ||
"readOnly": true | ||
}, | ||
"created": { | ||
"description": "The GMT date the application password was created.", | ||
"anyOf": [ | ||
{ | ||
"$ref": "properties/date-time.json" | ||
} | ||
], | ||
"readOnly": true | ||
}, | ||
"last_used": { | ||
"description": "The GMT date the application password was last used.", | ||
"anyOf": [ | ||
{ | ||
"$ref": "properties/date-time.json" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"readOnly": true | ||
}, | ||
"last_ip": { | ||
"description": "The IP address the application password was last used by.", | ||
"type": [ | ||
"string", | ||
"null" | ||
], | ||
"format": "ipv4", | ||
"readOnly": true | ||
}, | ||
"_links": { | ||
"$ref": "properties/object-links.json" | ||
} | ||
} | ||
} |
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,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/hyper-schema#", | ||
"$id": "https://raw.githubusercontent.com/johnbillion/wp-json-schemas/trunk/schemas/rest-api/application-passwords.json", | ||
"title": "WP_REST_API_Application_Passwords", | ||
"description": "A collection of user application passwords in a REST API context.", | ||
"type": "array", | ||
"items": { | ||
"$ref": "application-password.json" | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace WPJsonSchemas; | ||
|
||
$user = wp_get_current_user(); | ||
$args = [ | ||
'name' => 'Hello', | ||
]; | ||
$created = \WP_Application_Passwords::create_new_application_password( $user->ID, wp_slash( $args ) ); | ||
|
||
$view_data = get_rest_response( 'GET', '/wp/v2/users/me/application-passwords', [ | ||
'context' => 'view', | ||
] ); | ||
$edit_data = get_rest_response( 'GET', '/wp/v2/users/me/application-passwords', [ | ||
'context' => 'edit', | ||
] ); | ||
save_rest_array( [ | ||
$view_data, | ||
$edit_data, | ||
], 'application-passwords' ); |
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