OpenAPI: make pass/password parameter a password schema
@@ -7,6 +7,7 @@ import io.jooby.Router;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.Content;
import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.responses.ApiResponse;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Opcodes;
@@ -56,11 +57,13 @@ public class RouteParser {
* Parameters:
*/
for (io.swagger.v3.oas.models.parameters.Parameter parameter : parameters) {
- Schema schema = parameter.getSchema();
- if (schema == null) {
+ if (parameter.getSchema() == null) {
String javaType = ((ParameterExt) parameter).getJavaType();
Optional.ofNullable(ctx.schema(javaType)).ifPresent(parameter::setSchema);
}
+ if (parameter.getSchema() instanceof StringSchema && isPassword(parameter.getName())) {
+ parameter.getSchema().setFormat("password");
+ }
}
/**
* Request body
@@ -118,6 +121,10 @@ public class RouteParser {
return result;
}
+ private boolean isPassword(String name) {
+ return "password".equalsIgnoreCase(name) || "pass".equalsIgnoreCase(name);
+ }
+
private void uniqueOperationId(List<OperationExt> operations) {
Map<String, AtomicInteger> names = new HashMap<>();
for (OperationExt operation : operations) {
