diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java index 9f09d9c5cb14..c5206ec9cdb1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -772,7 +772,11 @@ private String enumValuesToEnumTypeUnion(List values, String dataType) { private String numericEnumValuesToEnumTypeUnion(List values) { List stringValues = new ArrayList<>(); for (Number value : values) { - stringValues.add(value.toString()); + if (value == null) { + LOGGER.warn("An enum value was null. See https://github.com/swagger-api/swagger-core/issues/4223"); + } else { + stringValues.add(value.toString()); + } } return enumValuesToEnumTypeUnion(stringValues, "number"); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/N4jsClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/N4jsClientCodegen.java index 2448f1dc7e00..7c706a1b5e97 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/N4jsClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/N4jsClientCodegen.java @@ -595,7 +595,11 @@ private String enumValuesToEnumTypeUnion(List values, String dataType) { private String numericEnumValuesToEnumTypeUnion(List values) { List stringValues = new ArrayList<>(); for (Number value : values) { - stringValues.add(value.toString()); + if (value == null) { + LOGGER.warn("An enum value was null. See https://github.com/swagger-api/swagger-core/issues/4223"); + } else { + stringValues.add(value.toString()); + } } return enumValuesToEnumTypeUnion(stringValues, "number"); } diff --git a/modules/openapi-generator/src/test/resources/1_2/petstore-1.2/user b/modules/openapi-generator/src/test/resources/1_2/petstore-1.2/user index c9eb3f6ff783..ef0bdf4488d4 100644 --- a/modules/openapi-generator/src/test/resources/1_2/petstore-1.2/user +++ b/modules/openapi-generator/src/test/resources/1_2/petstore-1.2/user @@ -244,7 +244,8 @@ "description": "The password for login in clear text", "required": true, "type": "string", - "paramType": "query" + "paramType": "query", + "format": "password" } ], "responseMessages": [ @@ -278,7 +279,8 @@ "type": "string" }, "password": { - "type": "string" + "type": "string", + "format": "password" }, "phone": { "type": "string" diff --git a/modules/openapi-generator/src/test/resources/2_0/c/petstore.yaml b/modules/openapi-generator/src/test/resources/2_0/c/petstore.yaml index b7ea03b1c779..10131f919bcb 100644 --- a/modules/openapi-generator/src/test/resources/2_0/c/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/c/petstore.yaml @@ -632,6 +632,7 @@ paths: description: The password for login in clear text required: true type: string + format: password responses: '200': description: successful operation @@ -872,6 +873,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/globalSecurity.json b/modules/openapi-generator/src/test/resources/2_0/globalSecurity.json index efecc7ee6b48..fec8e891d350 100644 --- a/modules/openapi-generator/src/test/resources/2_0/globalSecurity.json +++ b/modules/openapi-generator/src/test/resources/2_0/globalSecurity.json @@ -652,7 +652,8 @@ "in": "query", "description": "The password for login in clear text", "required": false, - "type": "string" + "type": "string", + "format": "password" } ], "responses": { @@ -861,7 +862,8 @@ "type": "string" }, "password": { - "type": "string" + "type": "string", + "format": "password" }, "phone": { "type": "string" diff --git a/modules/openapi-generator/src/test/resources/2_0/long_description_issue_7839.json b/modules/openapi-generator/src/test/resources/2_0/long_description_issue_7839.json index e50678f6cdd0..4010bb3aeb9a 100644 --- a/modules/openapi-generator/src/test/resources/2_0/long_description_issue_7839.json +++ b/modules/openapi-generator/src/test/resources/2_0/long_description_issue_7839.json @@ -503,7 +503,8 @@ "in" : "query", "description" : "The password for login in clear text", "required" : true, - "type" : "string" + "type" : "string", + "format": "password" } ], "responses" : { "200" : { @@ -711,7 +712,8 @@ "type" : "string" }, "password" : { - "type" : "string" + "type" : "string", + "format" : "password" }, "phone" : { "type" : "string" diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-bash.json b/modules/openapi-generator/src/test/resources/2_0/petstore-bash.json index cc93278ae86a..327e3bca1da9 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-bash.json +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-bash.json @@ -698,7 +698,8 @@ "in":"query", "description":"The password for login in clear text", "required":true, - "type":"string" + "type":"string", + "format":"password" } ], "responses":{ @@ -942,7 +943,8 @@ "type":"string" }, "password":{ - "type":"string" + "type":"string", + "format": "password" }, "phone":{ "type":"string" diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-nullable.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-nullable.yaml index b68004726ed8..9e232332bcbf 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-nullable.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-nullable.yaml @@ -452,6 +452,7 @@ paths: description: The password for login in clear text required: true type: string + format: password responses: '200': description: successful operation @@ -625,6 +626,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-orig.json b/modules/openapi-generator/src/test/resources/2_0/petstore-orig.json index 9f8689649350..8a7875edb6ee 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-orig.json +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-orig.json @@ -652,7 +652,8 @@ "in": "query", "description": "The password for login in clear text", "required": false, - "type": "string" + "type": "string", + "format": "password" } ], "responses": { @@ -828,7 +829,8 @@ "type": "string" }, "password": { - "type": "string" + "type": "string", + "format": "password" }, "phone": { "type": "string" diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml index 77cbbb72c3b8..71c0d56915a4 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml @@ -453,6 +453,7 @@ paths: description: The password for login in clear text required: true type: string + format: password responses: '200': description: successful operation @@ -626,6 +627,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-vendor-mime.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-vendor-mime.yaml index 118f66d37acb..1d7e5c5d001e 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-vendor-mime.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-vendor-mime.yaml @@ -448,6 +448,7 @@ paths: description: The password for login in clear text required: true type: string + format: password responses: '200': description: successful operation @@ -839,6 +840,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-date-field.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-date-field.yaml index 28d56302b7b8..09988324aa09 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-date-field.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-date-field.yaml @@ -442,6 +442,7 @@ paths: description: The password for login in clear text required: true type: string + format: password responses: '200': description: successful operation @@ -615,6 +616,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-for-testing-playframework-with-security.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-for-testing-playframework-with-security.yaml index 4ef75a199d37..c6ec5afb9cac 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-for-testing-playframework-with-security.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-for-testing-playframework-with-security.yaml @@ -181,6 +181,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-saga-and-records.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-saga-and-records.yaml index babf447f2f1a..f6c00bfa4951 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-saga-and-records.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-saga-and-records.yaml @@ -639,6 +639,7 @@ paths: description: The password for login in clear text required: true type: string + format: password responses: '200': description: successful operation @@ -822,6 +823,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml index b903c4f68c21..b318b67bb716 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml @@ -482,6 +482,7 @@ paths: description: The password for login in clear text required: true type: string + format: password responses: '200': description: successful operation @@ -1323,6 +1324,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-operations-without-required-params.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-operations-without-required-params.yaml index cdc9e693f444..8a2de32adb8e 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-operations-without-required-params.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-operations-without-required-params.yaml @@ -449,6 +449,7 @@ paths: description: The password for login in clear text required: true type: string + format: password responses: '200': description: successful operation @@ -622,6 +623,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml index fbf17da64240..8f127576ba6a 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml @@ -476,6 +476,7 @@ paths: description: The password for login in clear text required: true type: string + format: password responses: '200': description: successful operation @@ -658,6 +659,7 @@ definitions: type: string password: type: string + format: password phone: type: string userStatus: diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore.json b/modules/openapi-generator/src/test/resources/2_0/petstore.json index 5deda4b94ce5..9108563a9377 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore.json +++ b/modules/openapi-generator/src/test/resources/2_0/petstore.json @@ -663,7 +663,8 @@ "in": "query", "description": "The password for login in clear text", "required": false, - "type": "string" + "type": "string", + "format": "password" } ], "responses": { @@ -839,7 +840,8 @@ "type": "string" }, "password": { - "type": "string" + "type": "string", + "format": "password" }, "phone": { "type": "string" diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore_issue_7999.json b/modules/openapi-generator/src/test/resources/2_0/petstore_issue_7999.json index c48c37f0f9a4..493fce847cbe 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore_issue_7999.json +++ b/modules/openapi-generator/src/test/resources/2_0/petstore_issue_7999.json @@ -663,7 +663,8 @@ "in": "query", "description": "The password for login in clear text", "required": false, - "type": "string" + "type": "string", + "format": "password" } ], "responses": { @@ -839,7 +840,8 @@ "type": "string" }, "password": { - "type": "string" + "type": "string", + "format": "password" }, "phone": { "type": "string" diff --git a/modules/openapi-generator/src/test/resources/2_0/wordnik.json b/modules/openapi-generator/src/test/resources/2_0/wordnik.json index ca4ec3ef45c5..9138cfe97cd8 100644 --- a/modules/openapi-generator/src/test/resources/2_0/wordnik.json +++ b/modules/openapi-generator/src/test/resources/2_0/wordnik.json @@ -67,7 +67,8 @@ "in": "query", "description": "The user's password", "required": true, - "type": "string" + "type": "string", + "format": "password" } ], "responses": { @@ -1657,7 +1658,8 @@ "type": "string" }, "password": { - "type": "string" + "type": "string", + "format": "password" } } }, diff --git a/modules/openapi-generator/src/test/resources/2_0/wordnik.yaml b/modules/openapi-generator/src/test/resources/2_0/wordnik.yaml index ce95ec32539a..98fe03412621 100644 --- a/modules/openapi-generator/src/test/resources/2_0/wordnik.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/wordnik.yaml @@ -429,6 +429,7 @@ paths: description: "The user's password" required: true type: string + format: password responses: '200': description: A valid authentication token @@ -1352,6 +1353,7 @@ definitions: type: string password: type: string + format: password WordOfTheDay: properties: definitions: diff --git a/modules/openapi-generator/src/test/resources/3_0/jetbrains/ManagementService-v3.json b/modules/openapi-generator/src/test/resources/3_0/jetbrains/ManagementService-v3.json index 74b530588bdb..6353bfe45d37 100644 --- a/modules/openapi-generator/src/test/resources/3_0/jetbrains/ManagementService-v3.json +++ b/modules/openapi-generator/src/test/resources/3_0/jetbrains/ManagementService-v3.json @@ -16028,7 +16028,8 @@ }, "password" : { "description" : "The password for the API credential that was created.", - "type" : "string" + "type" : "string", + "format" : "password" }, "roles" : { "description" : "List of [roles](https://docs.adyen.com/development-resources/api-credentials#roles-1) for the API credential.", @@ -16134,7 +16135,8 @@ }, "password" : { "description" : "The password for the API credential that was created.", - "type" : "string" + "type" : "string", + "format" : "password" }, "roles" : { "description" : "List of [roles](https://docs.adyen.com/development-resources/api-credentials#roles-1) for the API credential.", @@ -16355,7 +16357,8 @@ }, "password" : { "description" : "Password to access the webhook URL.", - "type" : "string" + "type" : "string", + "format" : "password" }, "populateSoapActionHeader" : { "description" : "Indicates if the SOAP action header needs to be populated. Default value: **false**.\n\nOnly applies if `communicationFormat`: **soap**.", @@ -16584,7 +16587,8 @@ }, "password" : { "description" : "Password to access the webhook URL.", - "type" : "string" + "type" : "string", + "format" : "password" }, "populateSoapActionHeader" : { "description" : "Indicates if the SOAP action header needs to be populated. Default value: **false**.\n\nOnly applies if `communicationFormat`: **soap**.", @@ -20193,7 +20197,8 @@ }, "password" : { "description" : "Password to access the webhook URL.", - "type" : "string" + "type" : "string", + "format" : "password" }, "populateSoapActionHeader" : { "description" : "Indicates if the SOAP action header needs to be populated. Default value: **false**.\n\nOnly applies if `communicationFormat`: **soap**.", @@ -20333,7 +20338,8 @@ }, "password" : { "description" : "Password to access the webhook URL.", - "type" : "string" + "type" : "string", + "format" : "password" }, "populateSoapActionHeader" : { "description" : "Indicates if the SOAP action header needs to be populated. Default value: **false**.\n\nOnly applies if `communicationFormat`: **soap**.", @@ -20665,7 +20671,8 @@ }, "password" : { "description" : "The password for authentication of the notifications.", - "type" : "string" + "type" : "string", + "format" : "password" }, "url" : { "description" : "The URL in the format: http(s)://domain.com.", diff --git a/modules/openapi-generator/src/test/resources/3_0/jetbrains/MgmtApi.json b/modules/openapi-generator/src/test/resources/3_0/jetbrains/MgmtApi.json index 3b8a3c9e03fa..d642880efa3e 100644 --- a/modules/openapi-generator/src/test/resources/3_0/jetbrains/MgmtApi.json +++ b/modules/openapi-generator/src/test/resources/3_0/jetbrains/MgmtApi.json @@ -16118,7 +16118,8 @@ }, "password" : { "description" : "The password for the API credential that was created.", - "type" : "string" + "type" : "string", + "format" : "password" }, "roles" : { "description" : "List of [roles](https://docs.adyen.com/development-resources/api-credentials#roles-1) for the API credential.", @@ -16224,7 +16225,8 @@ }, "password" : { "description" : "The password for the API credential that was created.", - "type" : "string" + "type" : "string", + "format" : "password" }, "roles" : { "description" : "List of [roles](https://docs.adyen.com/development-resources/api-credentials#roles-1) for the API credential.", @@ -16445,7 +16447,8 @@ }, "password" : { "description" : "Password to access the webhook URL.", - "type" : "string" + "type" : "string", + "format" : "password" }, "populateSoapActionHeader" : { "description" : "Indicates if the SOAP action header needs to be populated. Default value: **false**.\n\nOnly applies if `communicationFormat`: **soap**.", @@ -16674,7 +16677,8 @@ }, "password" : { "description" : "Password to access the webhook URL.", - "type" : "string" + "type" : "string", + "format" : "password" }, "populateSoapActionHeader" : { "description" : "Indicates if the SOAP action header needs to be populated. Default value: **false**.\n\nOnly applies if `communicationFormat`: **soap**.", @@ -20184,7 +20188,8 @@ }, "password" : { "description" : "Password to access the webhook URL.", - "type" : "string" + "type" : "string", + "format" : "password" }, "populateSoapActionHeader" : { "description" : "Indicates if the SOAP action header needs to be populated. Default value: **false**.\n\nOnly applies if `communicationFormat`: **soap**.", @@ -20324,7 +20329,8 @@ }, "password" : { "description" : "Password to access the webhook URL.", - "type" : "string" + "type" : "string", + "format" : "password" }, "populateSoapActionHeader" : { "description" : "Indicates if the SOAP action header needs to be populated. Default value: **false**.\n\nOnly applies if `communicationFormat`: **soap**.", @@ -20645,7 +20651,8 @@ }, "password" : { "description" : "The password for authentication of the notifications.", - "type" : "string" + "type" : "string", + "format" : "password" }, "url" : { "description" : "The URL in the format: http(s)://domain.com.", diff --git a/modules/openapi-generator/src/test/resources/3_0/snakecase-discriminator.yaml b/modules/openapi-generator/src/test/resources/3_0/snakecase-discriminator.yaml index cc4f62fa3972..68d1acf558f0 100644 --- a/modules/openapi-generator/src/test/resources/3_0/snakecase-discriminator.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/snakecase-discriminator.yaml @@ -471,6 +471,7 @@ paths: required: true schema: type: string + format: password responses: "200": description: successful operation diff --git a/modules/openapi-generator/src/test/resources/petstore.json b/modules/openapi-generator/src/test/resources/petstore.json index ad5523181b6a..1f159bffac96 100644 --- a/modules/openapi-generator/src/test/resources/petstore.json +++ b/modules/openapi-generator/src/test/resources/petstore.json @@ -652,7 +652,8 @@ "in": "query", "description": "The password for login in clear text", "required": false, - "type": "string" + "type": "string", + "format": "password" } ], "responses": { @@ -840,7 +841,8 @@ "type": "string" }, "password": { - "type": "string" + "type": "string", + "format": "password" }, "phone": { "type": "string" diff --git a/samples/openapi3/client/petstore/typescript/builds/explode-query/apis/UserApi.ts b/samples/openapi3/client/petstore/typescript/builds/explode-query/apis/UserApi.ts index b6f4a6c226cf..c208b23dbda0 100644 --- a/samples/openapi3/client/petstore/typescript/builds/explode-query/apis/UserApi.ts +++ b/samples/openapi3/client/petstore/typescript/builds/explode-query/apis/UserApi.ts @@ -242,7 +242,7 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory { // Query Params if (password !== undefined) { - requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string", "")); + requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string", "password")); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/User.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/User.java index 05c00bda2e2d..30a74f4abe66 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/User.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/User.java @@ -216,7 +216,7 @@ public String toString() { sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); sb.append(" email: ").append(toIndentedString(email)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" password: ").append("*").append("\n"); sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); sb.append("}"); diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/public/openapi.json b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/public/openapi.json index caab0808595f..14511b6f1cf8 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/public/openapi.json +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/public/openapi.json @@ -230,6 +230,7 @@ "type" : "string" }, "password" : { + "format" : "password", "type" : "string" }, "phone" : { diff --git a/samples/server/petstore/kotlin-springboot-springfox/src/main/resources/openapi.yaml b/samples/server/petstore/kotlin-springboot-springfox/src/main/resources/openapi.yaml new file mode 100644 index 000000000000..e69de29bb2d1