@Test public void testOperationIdSanitizer() { assertThat(OpenAPI3Utils.sanitizeOperationId("operationId")).isEqualTo("operationId"); assertThat(OpenAPI3Utils.sanitizeOperationId("operation id")).isEqualTo("operationId"); assertThat(OpenAPI3Utils.sanitizeOperationId("operation Id")).isEqualTo("operationId"); assertThat(OpenAPI3Utils.sanitizeOperationId("operation-id")).isEqualTo("operationId"); assertThat(OpenAPI3Utils.sanitizeOperationId("operation_id")).isEqualTo("operationId"); assertThat(OpenAPI3Utils.sanitizeOperationId("operation__id-")).isEqualTo("operationId"); assertThat(OpenAPI3Utils.sanitizeOperationId("operation_- id ")).isEqualTo("operationId"); assertThat(OpenAPI3Utils.sanitizeOperationId("operation_- A B")).isEqualTo("operationAB"); }
protected static String sanitizeOperationId(String operationId) { StringBuilder result = new StringBuilder(); for (int i = 0; i < operationId.length(); i++) { char c = operationId.charAt(i); if (c == '-' || c == ' ' || c == '_') { try { while (c == '-' || c == ' ' || c == '_') { i++; c = operationId.charAt(i); } result.append(Character.toUpperCase(operationId.charAt(i))); } catch (StringIndexOutOfBoundsException e) { } } else { result.append(c); } } return result.toString(); }
OpenAPI3Utils { protected static String sanitizeOperationId(String operationId) { StringBuilder result = new StringBuilder(); for (int i = 0; i < operationId.length(); i++) { char c = operationId.charAt(i); if (c == '-' || c == ' ' || c == '_') { try { while (c == '-' || c == ' ' || c == '_') { i++; c = operationId.charAt(i); } result.append(Character.toUpperCase(operationId.charAt(i))); } catch (StringIndexOutOfBoundsException e) { } } else { result.append(c); } } return result.toString(); } }
OpenAPI3Utils { protected static String sanitizeOperationId(String operationId) { StringBuilder result = new StringBuilder(); for (int i = 0; i < operationId.length(); i++) { char c = operationId.charAt(i); if (c == '-' || c == ' ' || c == '_') { try { while (c == '-' || c == ' ' || c == '_') { i++; c = operationId.charAt(i); } result.append(Character.toUpperCase(operationId.charAt(i))); } catch (StringIndexOutOfBoundsException e) { } } else { result.append(c); } } return result.toString(); }  }
OpenAPI3Utils { protected static String sanitizeOperationId(String operationId) { StringBuilder result = new StringBuilder(); for (int i = 0; i < operationId.length(); i++) { char c = operationId.charAt(i); if (c == '-' || c == ' ' || c == '_') { try { while (c == '-' || c == ' ' || c == '_') { i++; c = operationId.charAt(i); } result.append(Character.toUpperCase(operationId.charAt(i))); } catch (StringIndexOutOfBoundsException e) { } } else { result.append(c); } } return result.toString(); }   }
OpenAPI3Utils { protected static String sanitizeOperationId(String operationId) { StringBuilder result = new StringBuilder(); for (int i = 0; i < operationId.length(); i++) { char c = operationId.charAt(i); if (c == '-' || c == ' ' || c == '_') { try { while (c == '-' || c == ' ' || c == '_') { i++; c = operationId.charAt(i); } result.append(Character.toUpperCase(operationId.charAt(i))); } catch (StringIndexOutOfBoundsException e) { } } else { result.append(c); } } return result.toString(); }    }