forked from loafle/openapi-generator-original
[Bug] fix: use length to check for default return media type (#15833)
* fix: use length to check for default return media type as `mediaTypes` is an array of strings and an required argument it will never be undefined when we can rely on the typesystem. However, it can be zero length(`[]`) and in this case we would throw. * Closes #15011 * chore: update examples
This commit is contained in:
@@ -196,7 +196,7 @@ export class ObjectSerializer {
|
||||
*/
|
||||
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||
/** According to OAS 3 we should default to json */
|
||||
if (!mediaTypes) {
|
||||
if (mediaTypes.length === 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ export class ObjectSerializer {
|
||||
*/
|
||||
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||
/** According to OAS 3 we should default to json */
|
||||
if (!mediaTypes) {
|
||||
if (mediaTypes.length === 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ export class ObjectSerializer {
|
||||
*/
|
||||
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||
/** According to OAS 3 we should default to json */
|
||||
if (!mediaTypes) {
|
||||
if (mediaTypes.length === 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ export class ObjectSerializer {
|
||||
*/
|
||||
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||
/** According to OAS 3 we should default to json */
|
||||
if (!mediaTypes) {
|
||||
if (mediaTypes.length === 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ export class ObjectSerializer {
|
||||
*/
|
||||
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||
/** According to OAS 3 we should default to json */
|
||||
if (!mediaTypes) {
|
||||
if (mediaTypes.length === 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ export class ObjectSerializer {
|
||||
*/
|
||||
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||
/** According to OAS 3 we should default to json */
|
||||
if (!mediaTypes) {
|
||||
if (mediaTypes.length === 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ export class ObjectSerializer {
|
||||
*/
|
||||
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||
/** According to OAS 3 we should default to json */
|
||||
if (!mediaTypes) {
|
||||
if (mediaTypes.length === 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ export class ObjectSerializer {
|
||||
*/
|
||||
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||
/** According to OAS 3 we should default to json */
|
||||
if (!mediaTypes) {
|
||||
if (mediaTypes.length === 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ export class ObjectSerializer {
|
||||
*/
|
||||
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||
/** According to OAS 3 we should default to json */
|
||||
if (!mediaTypes) {
|
||||
if (mediaTypes.length === 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user