Skip to content
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

schema for "/__experimental/menu-items" errors #34628

Closed
MohammedFaragallah opened this issue Sep 8, 2021 · 7 comments · Fixed by #34670
Closed

schema for "/__experimental/menu-items" errors #34628

MohammedFaragallah opened this issue Sep 8, 2021 · 7 comments · Fixed by #34670
Assignees
Labels
REST API Interaction Related to REST API [Status] In Progress Tracking issues with work in progress [Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed.

Comments

@MohammedFaragallah
Copy link
Contributor

I'm not sure any if these cases are intentional but,

if ( 'nav_menu' === $taxonomy->name ) {
$schema['properties'][ $base ]['type'] = 'integer';
unset( $schema['properties'][ $base ]['items'] );
}

this endpoint return array of numbers for menus not a number

$schema['properties']['_invalid'] = array(
'description' => __( 'Whether the menu item represents an object that no longer exists.', 'gutenberg' ),
'context' => array( 'view', 'edit', 'embed' ),
'type' => 'boolean',
'readonly' => true,
);

also _invalid is missing not null or any falsy value

@talldan
Copy link
Contributor

talldan commented Sep 8, 2021

cc @spacedmonkey

@spacedmonkey
Copy link
Member

Hello @MohammedFaragallah I am developer of this endpoint.

Let me explain these schema issues.

if ( 'nav_menu' === $taxonomy->name ) {
$schema['properties'][ $base ]['type'] = 'integer';
unset( $schema['properties'][ $base ]['items'] );
}

This is not a mistake. A menu item can not be assigned to multiple menus. So I highjacked the schema, so that you only assign it to one endpoint.

$schema['properties']['_invalid'] = array(
'description' => __( 'Whether the menu item represents an object that no longer exists.', 'gutenberg' ),
'context' => array( 'view', 'edit', 'embed' ),
'type' => 'boolean',
'readonly' => true,
);

I will look into this

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Sep 8, 2021
@MohammedFaragallah
Copy link
Contributor Author

@spacedmonkey thank you for your fast response

This is not a mistake. A menu item can not be assigned to multiple menus. So I highjacked the schema so that you only assign it to one endpoint.

maybe add maxItems to match the endpoint array response/or change the response to a number

if ( 'nav_menu' === $taxonomy->name ) { 
	$schema['properties'][ $base ]['maxItems'] = 1; 
} 

@spacedmonkey
Copy link
Member

maybe add maxItems to match the endpoint array response/or change the response to a number

I don't like this idea, personally. Thoughts @TimothyBJacobs ?

@MohammedFaragallah
Copy link
Contributor Author

@spacedmonkey just a question does the schema represent the response?

I'm asking because I'm generating typescript definitions from it to make the response typesafe

it's working fine even with third-party plugins

@spacedmonkey
Copy link
Member

@MohammedFaragallah I have pushed a couple of fixes. The schema should match up now. Can you checkout trunk and see if fixes your issues.

@skorasaurus skorasaurus added the [Status] Needs More Info Follow-up required in order to be actionable. label May 5, 2022
@github-actions
Copy link

Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REST API Interaction Related to REST API [Status] In Progress Tracking issues with work in progress [Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants