Hi agussuroyo,
I found wrong logic make Tags args not working. Could you please update code in wp-api-swaggerui/wp-api-swaggerui.php and update new version?
Old code: (Line 227)
if (isset($args['tags']) && is_array($args['tags'])) {
$tags = $args['tags'];
}
To New code (Remove ‘s’ character in $args variable)
if (isset($arg['tags']) && is_array($arg['tags'])) {
$tags = $arg['tags'];
}
And can you share your github/gitlab repository to me? I found some bugs related to UI/UX when using this to Query Monitor. I want to folk and fix them.
Thank you
]]>Ciao WordPress forum,
I’ve been using this plugin but I am encountering a problem: when accessing the api doc, this is not generating models (as you can see from the image) and this implies the swagger is INVALID.
What could be the issue?
]]>I managed to enable custom parameters and it is working great, but how can I get rid of the default “wpml_language” parameter?
]]>Great Plugin by the way, but I have found that when I request an endpoint that is large the browser crashes. I tried in Chrome and in Firefox using the authorise me feature.
Any idea why this may be happening?
Link to video https://screenrec.com/share/CRjoJxeytl
]]>i have a issue of add Add Bearer token in webview. i added the token in rest api end points like this
'securityDefinitions' => [
'securitySchemes' => [
'bearerAuth' => [
'type' => 'http',
'scheme' => 'bearer',
'bearerFormat' => 'JWT',
'value' => 'ThisIsASampleToken123'
],
]
]
but in webview when i test my api the token will be empty. can someone guide me how can add a header option in webview or any other option ?
thanku for your help.
Howdy,
Thanks for the plugin, it is awesome and works very well! (Tested on WordPress 6.0)
It would be awesome to have the unminified version of the assets available, though. Do you think you could include them in some next release?
Thank you!
]]>/wp/rest-api/schema
Not sure what the URL is with older versions of WP, but I tried the above URL and no luck.
]]>Hello There,
I’ve some questions about this plugin, is this plugin compatible with Meta Box plugin? Because if I activate the WP API SwaggerUI plugin, the Feature Custom Fields on the Meta Box is broken.
Thank you
]]>Having a strange thing occurring lately and don’t think it’s related to the plugin but either an update to WordPress or cURL on the server or something else…
Recently, I’m getting the follow error when using Swagger UI to perform test calls:
{
"code": "rest_forbidden_context",
"message": "Sorry, you are not authorized to view this content.",
"data": {
"status": 401
}
}
But only when testing via the documentation page; If I copy/paste the cURL command directly in the server, or make the actual remote api request via Postman or Insomnia there are no issues… The authentication parameters look correct, it just appears that it’s being rejected for some reason…. not exactly sure why… figured I post the question here in case anyone can shed some light.
Thanks!
]]>Hi, I tried to update WooCommerce product meta_data via PUT or PATCH but always got a 400 eror. I used all possible formats for meta_data object but all were rejected with same message:
{
"code": "rest_invalid_param",
"message": "Invalid parameter(s): meta_data",
"data": {
"status": 400,
"params": {
"meta_data": "meta_data[0] is not of type object."
},
"details": {
"meta_data": {
"code": "rest_invalid_type",
"message": "meta_data[0] is not of type object.",
"data": {
"param": "meta_data[0]"
}
}
}
}
}
]]>
I installed a WP instance, installed wp-api-swaggerui plugin, but now, I don’t know what to do.
I have a json file from my api, published in a gateway, but I not know what are the next steps.
Can someone give a explanation or point for some page? Google also not help to find a suggestion for it.
Since now, thanks in advance.
Regards,
Claudio Ferreira
how you add a text area which you can have default values for example
[
{
"product_id":10,
"weight":"1",
"length":"1200",
"width":"20",
"height":"300",
"customer_postcode":"8021"
},
{
"product_id":37,
"weight":"12",
"length":"12300",
"width":"2340",
"height":"3010",
"customer_postcode":"8021"
}
]
Is there any parameter to add a text area?
]]>Hi,
When I open Swaggerfor a WordPress/WooCommerce site I get an error at the end of the page:
{“schemaValidationMessages”:[{“level”:”error”,”domain”:”validation”,”keyword”:”oneOf”,”message”:”instance failed to match exactly one schema (matched 0 out of 2)”,”schema”:{“loadingURI”:”https://swagger.io/v2/schema.json#”,”pointer”:”/definitions/parametersList/items”},”instance”:{“pointer”:”/paths/~1wc~1v3~1coupons/post/parameters/19″}}]}
The last METHOD that shows correctly is:
data
…
/wc/v3/data/currencies/{currency}
Any idea what coud be the cause ?
I have tested in 2 different sites and the error is the same.
Thanks
]]>Hello, in simple products it updates correctly, but in variable products the change does not impact.
The response code is 200, but Response body is: []
Any suggestion?
https://www.dropbox.com/s/i6giqnvb8iijior/error-swagger-01.jpg
]]>If you look at website.com/wp-json it provides all rest api endpoints not just wordpress core.
Would it be possible to add those as well?
]]>Hi, great plugin!
Is there any hook I could use to somehow restrict access to the API docs pages only to administrators? for time reasons I added the following directly on the simple template file:
<?php
/* Template Name: Restricted to Admin only */
if ( !current_user_can('administrator')) {
get_template_part('error');
exit(0);
}
?>
But I know I shouldn’t modify the plugin directly. Is there anything else I could do?
Thank you!
I want to propose fix for params type = file
wp-content/plugins/wp-api-swaggerui/wp-api-swaggerui.php
method:getParametersFromArgs
could you please change
from
$parameters[$mtd][] = $this->buildParams($param, $mtd, $endpoint, [‘type’ => ‘string’]+ $detail);
to:
$parameters[$mtd][] = $this->buildParams($param, $mtd, $endpoint, array_merge([‘type’ => ‘string’], $detail));
and after that params with type=file will works properly
]]>Hello and thank you for the plugin!
We use the ACF rest api, as well as the WP one, so we would need 2 separate swagger pages, to see them both at the same time.
Currently we need to save one or the other, each time we need to see them, because it’s the same url / 1 api at a time.
Would it be possible to have the Swagger plugin dynamically use different urls, depending on the api it’s showing, rather than having to switch/save different apis on the same url every time?
Thank you!
]]>Dear Developer,
Could you please provide a detailed documentation for creating custom endpoint please.
]]>Hi,
I am facing error while updating JSON Fields. After updating all the fields also it is showing fields are empty. Any one please help me to resolve the issue.
Please check the below link https://i.postimg.cc/Bb5gWb6W/image.jpg
Thanks,
Pradeep
Hello
I’ve installed SwaggerUI on a new WordPress.
WP version is 5.5.1
Astra Thème version is 2.5.5
Other eytensions installed are :
Aksimet 4.1.6 (not activated)
Hello Dolly (not activated)
I’ve Swagge UI installed on other site :
https://gagnebin.tech/rest-api/docs/
Where the link is funcitonnal
Best regards
Pascal
Thanks for updating your plugin, adding “produces” parameter gets reflected fine by swagger interface showing them in “Response content type”.
My doubt is how to distinguish 2 different formats in the request parameter as I can’t see any difference when inspecting WordPress “$request_data” parameter in register_rest_route callback function.
Right now I use a GET parameter adding the format manually to the URL request, but it should be possible through the interface. When changing the format using “Response content type” curl adds an -H parameter to express the expected format. But the request URL itself doesn’t change, it always is https://xrcb.cat/ca/wp-json/xrcb/v1/radios
]]>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",
),
),
)
),
),
),
]);
]]>
I am a new baby for Swagger UI, how do I disable/remove Swagger in WordPress?
]]>Hi, i realize you may not be able to provide the needed direction. But from a past developer we have swagger docs setup for our API on a regular linux server elsewhere. I’d like to move them to a WordPress site and found your plugin. My skills are limited and I am not clear how I configure that using your plugin. I have it installed and I can view the default swagger page it creates at /rest-api/scheme. What I’m not sure about is how I configure it for the swagger docs I have elsewhere (i’ll get a copy of them). Is there a place I need to drop in the other files so it picks up our swagger docs? I tried to read through other topics and look at the code but I have to say I am unclear. Even some quick direction to point me in the right direction would be appreciated. Appreciate your help.
]]>I have troubles finding the a way to add certain elements as described in the OpenAPi specification to the swagger API documentation.
For example, I would like to define a summary and a description to the API methods, but can’t find out how.
Also I need to add geojson as an additional response content type. I tried to add it directly to the args parameter of register_rest_route, but without success:
`register_rest_route( ‘xrcb/v1’, ‘/radios/(?P<id>\d+)’, array(
‘methods’ => ‘GET’,
‘summary’ => ‘Find radio by ID.’,
‘description’ => ‘Returns a single radio.’,
‘produces’ => ‘application/vnd.geo+json’,
‘callback’ => ‘xrcbapi_radios_api_endpoint’,
‘args’ => array(
‘id’ => array(
‘description’ => esc_html__( ‘ID of radio to return’, ‘xrcb’ ),
‘type’ => ‘integer’,
‘prop_format’ => ‘int64’,
‘validate_callback’ => function($param, $request, $key) {
return is_numeric( $param );
}
),
),
));`
A complete example of register_rest_route would be great.
]]>When running WordPress in a subdirectory, like /dev in my case, swagger schema validator shows the following error:
"ECMA 262 regex \"^[^{}/ :\\\\]+(?::\\d+)?$\" does not match input string \"tracesmap.org/dev\""
The name of the subdirectory appears in host:
"host": "tracesmap.org/dev",
"basePath": "/wp-json",
Probably it should be moved to basePath instead?
]]>I registered a custom REST API endpoint to WordPress and it shows up correctly at the Swagger Docs page.
My API uses query parameters and I would like to add them to the parameters section of the WordPress Swagger Docs page.
I know to do that with plain Swagger, but I’m confused about how to define that parameters in WordPress so the get used by Swagger.
Any hint how to do that?
]]>It seems to default to https://localhosth/wp/rest-api/schema. I have numerous Swagger API docs I want to be able to display without requiring the user to type in the URL. Is there a way to get this plugin to handle this?
Any help appreciated,
Chris
hey,
i had a weird bug, after activating the plugin the REST API ran into a timeout. But only if i tried to authenticate.
You add in swaggerauth.php the filter 'determine_current_user'
with the corresponding handler function, but you didn’t set the priority to 20. In the handler function you remove and add the filter before and after the auth process with the priority of 20.
Longstory short:
this: add_filter( 'determine_current_user', [ $basic, 'handler' ] );
should be this: add_filter( 'determine_current_user', [ $basic, 'handler' ], 20 );
btw: on php 7.2 i don’t have this problem.
thank you!
]]>