Generated code for angular seems wrong in 5.3.0 and not working comparing to v.5.1.1
See original GitHub issueDescription
Generated code for angular seems wrong on 5.3.0 and not working comparing to v.5.1.1. Mising there
if (file !== undefined) {
formParams = formParams.append('file', <any>file) as any || formParams;
}
in generated code and therefore the file will be not send to server
openapi-generator version
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.3.0</version>
<executions>
<execution>
<id>generate-angular-menu-sources</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${bff-open-api-defintions-folder}/openapi/${bff-open-api-defintions-file}</inputSpec>
<output>${angularui-generated-dir}/bff</output>
<configOptions>
<serviceSuffix>Bff</serviceSuffix>
<serviceFileSuffix>.bff</serviceFileSuffix>
<enumPropertyNaming>UPPERCASE</enumPropertyNaming>
</configOptions>
<generatorName>typescript-angular</generatorName>
</configuration>
</execution>
</executions>
</plugin>
OpenAPI declaration file content or url
/startpage/{id}/picture:
post:
operationId: uploadPicture
description: 'uploadPicture'
requestBody:
description: 'uploadPicture'
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
required: true
Generated 5.1.1 code:
/**
* Get a specific Startpage
* @param id ID of the startpage item.
* @param file
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public uploadPicture(id: string, file: Blob, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<Startpage>;
public uploadPicture(id: string, file: Blob, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<HttpResponse<Startpage>>;
public uploadPicture(id: string, file: Blob, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<HttpEvent<Startpage>>;
public uploadPicture(id: string, file: Blob, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json'}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling uploadPicture.');
}
if (file === null || file === undefined) {
throw new Error('Required parameter file was null or undefined when calling uploadPicture.');
}
let headers = this.defaultHeaders;
let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (httpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = [
'multipart/form-data'
];
const canConsumeForm = this.canConsumeForm(consumes);
let formParams: { append(param: string, value: any): any; };
let useForm = false;
let convertFormParamsToString = false;
// use FormData to transmit files using content-type "multipart/form-data"
// see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data
useForm = canConsumeForm;
if (useForm) {
formParams = new FormData();
} else {
formParams = new HttpParams({encoder: this.encoder});
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) as any || formParams;
}
let responseType_: 'text' | 'json' = 'json';
if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}
return this.httpClient.post<Startpage>(`${this.configuration.basePath}/startpage/${encodeURIComponent(String(id))}/picture`,
convertFormParamsToString ? formParams.toString() : formParams,
{
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
Generated 5.3.0 code:
/**
* Get a specific Startpage
* @param id ID of the startpage item.
* @param file
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public uploadPicture(id: string, file: Blob, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Startpage>;
public uploadPicture(id: string, file: Blob, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Startpage>>;
public uploadPicture(id: string, file: Blob, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Startpage>>;
public uploadPicture(id: string, file: Blob, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling uploadPicture.');
}
if (file === null || file === undefined) {
throw new Error('Required parameter file was null or undefined when calling uploadPicture.');
}
let localVarHeaders = this.defaultHeaders;
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}
// to determine the Content-Type header
const consumes: string[] = [
'multipart/form-data'
];
const canConsumeForm = this.canConsumeForm(consumes);
let localVarFormParams: { append(param: string, value: any): any; };
let localVarUseForm = false;
let localVarConvertFormParamsToString = false;
if (localVarUseForm) {
localVarFormParams = new FormData();
} else {
localVarFormParams = new HttpParams({encoder: this.encoder});
}
let responseType_: 'text' | 'json' = 'json';
if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}
return this.httpClient.post<Startpage>(`${this.configuration.basePath}/startpage/${encodeURIComponent(String(id))}/picture`,
localVarConvertFormParamsToString ? localVarFormParams.toString() : localVarFormParams,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
node.js - Unable to migrate to angular 5 getting invalid error ...
When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on ......
Read more >Bug listing with status RESOLVED with resolution TEST ...
Bug:233 - "Emacs segfaults when merged through the sandbox." status:RESOLVED resolution:TEST-REQUEST severity:critical · Bug:3888 - "yenta_socket module not ...
Read more >Common Illnesses — Spyder 5 documentation
If you receive the message An error occurred while starting the kernel in the IPython Console, Spyder was unable to launch a new...
Read more >Releases - styled-components
Releases. Updating styled components is usually as simple as npm install . Only major versions have the potential to introduce breaking changes (noted...
Read more >Change Log - /dropdowns - Kendo UI for Angular - Telerik
Bug Fixes. filter directive does not work with ng10+ (#790); update copyright in README; combobox: clear button shown on hover when the component...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please try the latest master and reply if it’s still an issue.
@tz1010 thanks for the confirmation.
For other issues, please open a new issue to track it.