• Hello
    The swagger ui page doesn’t show the parameters of objects when editing. Is there a way to add them?

    My code:

    register_rest_route( $namespace, '/' . $path, [
    		  array(
    			'methods'             => WP_REST_Server::EDITABLE,
    			'callback'            => array( $this, 'proccess_request' ),
    			'permission_callback' => array( $this, 'get_items_permissions_check' ),
    			'consumes' => "application/json",
    			'args' =>  array(
    				'request_id' => array(
    					'validate_callback' => function($param, $request, $key) {
    						return is_numeric( $param );
    					},
    					'required' => true,
    					'type' => 'integer',
    					'description' => 'Your internal request id',
    				),
    				'object' => array(
    					'validate_callback' => function($param, $request, $key) {
    						return "products" === $param;
    					},
    					'required' => true,
    					'type' => 'string',
    					'description' => 'The object type to run the call against.',
    				),
    				'total_count' => array(
    					'validate_callback' => function($param, $request, $key) {
    						return is_numeric( $param );
    					},
    					'required' => false,
    					'type' => 'integer',
    					'description' => 'Total count of the products',
    				),
    
    				'data' => array(
    					'type' => 'array',
    					"items" => array(
    						"type" => "object",
    						"properties" => array(
    							'action' => array(
    								'required' => true,
    								"type" => "enum",
    								"enum" => array(
    									"add", "update"
    								)
    							),
    							"date_created" => array(
    								'required' => false,
    								"type" => "string",
    							),
    							"date_last_modified" => array(
    								'required' => false,
    								"type" => "string",
    							),
    						),
    					)
    				),
    
    			 ),
    
    		  ),
    		]);
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Properties of objects are not shown’ is closed to new replies.