Skip to content

Commit

Permalink
Get rid of additional properties in partials.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbillion committed Aug 20, 2024
1 parent 0de3454 commit 9a74435
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 0 additions & 5 deletions packages/wp-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2305,7 +2305,6 @@ interface WP_REST_API_Partial_Post_Common {
*/
tags?: number[];
_links: WP_REST_API_Object_Links;
[k: string]: unknown;
}
/**
* Hello.
Expand All @@ -2315,7 +2314,6 @@ interface WP_REST_API_Partial_Post_Author {
* The ID for the author of the post.
*/
author: number;
[k: string]: unknown;
}
/**
* Properties for public post types
Expand All @@ -2333,7 +2331,6 @@ interface WP_REST_API_Partial_Post_Public {
* An array of the class names for the post container element.
*/
class_list: string[];
[k: string]: unknown;
}
/**
* Properties for post types that support comments
Expand All @@ -2347,7 +2344,6 @@ interface WP_REST_API_Partial_Post_Comments {
* Whether or not the post can be pinged.
*/
ping_status: WP_Post_Comment_Status_Name;
[k: string]: unknown;
}
/**
* Properties for post types that support an excerpt
Expand All @@ -2370,7 +2366,6 @@ interface WP_REST_API_Partial_Post_Excerpt {
*/
protected: boolean;
};
[k: string]: unknown;
}
/**
* A media attachment object in a REST API context.
Expand Down
11 changes: 11 additions & 0 deletions tests/bin/build-wp-types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
# -o pipefail Produce a failure return code if any command errors
set -eo pipefail

for file in schemas/rest-api/partials/**/*.json
do
./node_modules/node-jq/bin/jq --tab '. + { "additionalProperties": false }' "$file" > tmp && mv tmp "$file"
done

./node_modules/.bin/json2ts -i schema.json -o packages/wp-types/index.ts --style.trailingComma=all --style.useTabs

for file in schemas/rest-api/partials/**/*.json
do
./node_modules/node-jq/bin/jq --tab 'del(.additionalProperties)' "$file" > tmp && mv tmp "$file"
done

cat packages/wp-types/append.ts >> packages/wp-types/index.ts
sed -i.bak 's/export interface WP_REST_API_Partial_/interface WP_REST_API_Partial_/g' packages/wp-types/index.ts
rm packages/wp-types/index.ts.bak

0 comments on commit 9a74435

Please sign in to comment.