cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

generated url is malformed (GET request) #82

Closed fromnowhereuser closed 4 years ago

fromnowhereuser commented 4 years ago

Hello, maybe i am doing it wrong but... i use nest with the swagger plugin. I have a service like:

@Get(':id')
@ApiCreatedResponse({
    description: '',
    type: [Automate],

}) async getMy(@Request() req, @Param() params: any): Promise<Array<Automate>> {
    return this.automateDao.getAllByUser(params.id);
}

The function generated with the json produced is like this:

automatesControllerGetMy$Response(params?: {

}): Observable<StrictHttpResponse<Array<Automate>>> {

const rb = new RequestBuilder(this.rootUrl, ApiService.AutomatesControllerGetMyPath, '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<Array<Automate>>;
  })
);

}

My question is, why there is nothing in the if(params) test. If i add something like: rb.path('id','aabbcc') the url is ok. but... i feel like i must not modify the code generated myself right ?

Its this a bug ? or i am missing something ? Thx you in advance

luisfpg commented 4 years ago

Can you share either the yaml or json for this operation, please?

fromnowhereuser commented 4 years ago

Ofc, thx you a lot !

    "/automates/{id}": {
        "get": {
            "operationId": "AutomatesController_getMy",
            "parameters": [],
            "responses": {
                "201": {
                    "description": "All automates are successfully returned",
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "array",
                                "items": {
                                    "$ref": "#/components/schemas/AutomateDto"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
luisfpg commented 4 years ago

You're missing the parameter in parameters.