Open codal-nwadhawana opened 4 years ago
Everything seems correct.
Can you debug in the browser the apiUserListing$Response
to check that parameters are being correctly set in the RequestBuilder
, and then the RequestBuilder.build
call?
hey @luisfpg,
thanks for quick response.
I am getting all the query params info RequestBuilder.build
function.
it works when i update this block of code in request-builder.ts
console.log("this._query.values()",this._query.values());
for (const queryParam of this._query.values()) {
httpParams = queryParam.append(httpParams);
}
to this
console.log("this._query.values()",this._query.values());
for (const queryParam of Array.from(this._query.values())) {
httpParams = queryParam.append(httpParams);
}
console output image : https://drive.google.com/file/d/1xWxMFkcP8cXABdDwH9w1jFMivpcacmN7/view
I am not able to save above change in my code. as, it will be generated from package.
is there any issue with my code or anything else?
I can't find an explanation for this... Which browser are you using? We have used this code for years and the requests always have the parameters correctly. See the https://github.com/cyclosproject/cyclos4-ui (there's a running demo on https://demo-ui.cyclos.org/). And all searches use query parameters...
I experience the same issue, and the problem is that the generated code is the following:
get2$Response(params?: {
}): Observable<StrictHttpResponse<PageDtoApiModel>> {
const rb = new RequestBuilder(this.rootUrl, TransactionControllerApiService.Get2Path, 'get');
if (params) {
}
return this.http.request(rb.build({
responseType: 'json',
accept: 'application/json'
})).pipe(
filter((r: any) => r instanceof HttpResponse),
map((r: HttpResponse<any>) => {
return r as StrictHttpResponse<PageDtoApiModel>;
})
);
}
As you can see, the generated code does nothing to the params, so they are not sent out.
@Vtfelker please, share the openapi definition (json or yaml) for your operation
{ "get": { "tags": [ "transaction-controller" ], "operationId": "get_2", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PageDTO" } } } }, "400": { "description": "Bad Request", "content": { "/": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } }
Well, the point is that you're not declaring any parameters in this operation. You need query parameters in order to have them generated.
@luisfpg
I suggest create flag on config file like anyParameters: true | false
. Wich add enable to add any parametrs to our services and function.
Becuase I have following problem. I need to send request like this:
http://localhost:1337/api/v1/navigation?populate[mainmenu][populate][0]=submenu
but my swagger json file doesnt allow dynamic params and I can't modify it (because it's autogenerated from CMS)
"parameters": [
{
"name": "sort",
"in": "query",
"description": "Sort by attributes ascending (asc) or descending (desc)",
"deprecated": false,
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "pagination[withCount]",
"in": "query",
"description": "Return page/pageSize (default: true)",
"deprecated": false,
"required": false,
"schema": {
"type": "boolean"
}
},
{
"name": "pagination[page]",
"in": "query",
"description": "Page number (default: 0)",
"deprecated": false,
"required": false,
"schema": {
"type": "integer"
}
},
{
"name": "pagination[pageSize]",
"in": "query",
"description": "Page size (default: 25)",
"deprecated": false,
"required": false,
"schema": {
"type": "integer"
}
},
{
"name": "pagination[start]",
"in": "query",
"description": "Offset value (default: 0)",
"deprecated": false,
"required": false,
"schema": {
"type": "integer"
}
},
{
"name": "pagination[limit]",
"in": "query",
"description": "Number of entities to return (default: 25)",
"deprecated": false,
"required": false,
"schema": {
"type": "integer"
}
},
{
"name": "fields",
"in": "query",
"description": "Fields to return (ex: title,author)",
"deprecated": false,
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "populate",
"in": "query",
"description": "Relations to return",
"deprecated": false,
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "filters",
"in": "query",
"description": "Filters to apply",
"deprecated": false,
"required": false,
"schema": {
"type": "object"
},
"style": "deepObject"
},
{
"name": "locale",
"in": "query",
"description": "Locale to apply",
"deprecated": false,
"required": false,
"schema": {
"type": "string"
}
}
],
as result I have following params:
if (params) {
rb.query('sort', params.sort, {});
rb.query('pagination[withCount]', params['pagination[withCount]'], {});
rb.query('pagination[page]', params['pagination[page]'], {});
rb.query('pagination[pageSize]', params['pagination[pageSize]'], {});
rb.query('pagination[start]', params['pagination[start]'], {});
rb.query('pagination[limit]', params['pagination[limit]'], {});
rb.query('fields', params.fields, {});
rb.query('populate', params.populate, {});
rb.query('filters', params.filters, {"style":"deepObject"});
rb.query('locale', params.locale, {});
}
In this case I can't to send my request from augenerated services and I need to create custom, only because I can't send custom params to request :(
hello,
I am trying to pass query params into GET request from service function which is generated By the package but the query params are not passed in the request.
please help me out this issue.
thanks in advance. :innocent:
My Swagger JSON object is
My request call
service functions generated from package