@Test public void shouldSanitizeTags() { assertThat(OasModelHelper.sanitizeTag("tag")).isEqualTo("tag"); assertThat(OasModelHelper.sanitizeTag(".]t%a$g#[/")).isEqualTo("tag"); final char[] str = new char[1024]; final String randomString = IntStream.range(0, str.length) .map(x -> (int) (Character.MAX_CODE_POINT * Math.random())).mapToObj(i -> new String(Character.toChars(i))) .collect(Collectors.joining("")); final String sanitized = OasModelHelper.sanitizeTag(randomString); assertThatCode(() -> JsonRecordSupport.validateKey(sanitized)).doesNotThrowAnyException(); }
public static String sanitizeTag(final String tag) { if (StringUtils.isEmpty(tag)) { return null; } final String sanitized = JSONDB_DISALLOWED_KEY_CHARS.matcher(tag).replaceAll("").trim(); if (sanitized.length() > 768) { return sanitized.substring(0, Math.min(tag.length(), 768)); } return sanitized; }
OasModelHelper { public static String sanitizeTag(final String tag) { if (StringUtils.isEmpty(tag)) { return null; } final String sanitized = JSONDB_DISALLOWED_KEY_CHARS.matcher(tag).replaceAll("").trim(); if (sanitized.length() > 768) { return sanitized.substring(0, Math.min(tag.length(), 768)); } return sanitized; } }
OasModelHelper { public static String sanitizeTag(final String tag) { if (StringUtils.isEmpty(tag)) { return null; } final String sanitized = JSONDB_DISALLOWED_KEY_CHARS.matcher(tag).replaceAll("").trim(); if (sanitized.length() > 768) { return sanitized.substring(0, Math.min(tag.length(), 768)); } return sanitized; } private  OasModelHelper(); }
OasModelHelper { public static String sanitizeTag(final String tag) { if (StringUtils.isEmpty(tag)) { return null; } final String sanitized = JSONDB_DISALLOWED_KEY_CHARS.matcher(tag).replaceAll("").trim(); if (sanitized.length() > 768) { return sanitized.substring(0, Math.min(tag.length(), 768)); } return sanitized; } private  OasModelHelper(); static OperationDescription operationDescriptionOf(final OasDocument openApiDoc, final OasOperation operation,
                                                              final BiFunction<String, String, String> consumer); static List<OasPathItem> getPathItems(OasPaths paths); static List<OasParameter> getParameters(final OasOperation operation); static List<OasParameter> getParameters(final OasPathItem pathItem); static String sanitizeTag(final String tag); static Stream<String> sanitizeTags(final List<String> list); static Map<String, OasOperation> getOperationMap(OasPathItem pathItem); static Map<String, T> getOperationMap(OasPathItem pathItem, Class<T> type); static String getReferenceName(String reference); static boolean isArrayType(OasSchema schema); static boolean isReferenceType(OasSchema schema); static boolean isReferenceType(OasParameter parameter); static boolean isBody(OasParameter parameter); static String getPropertyName(OasSchema schema); static String getPropertyName(OasSchema schema, String defaultName); static boolean isSerializable(OasParameter parameter); static boolean schemaIsNotSpecified(final OasSchema schema); static URI specificationUriFrom(final OasDocument openApiDoc); }
OasModelHelper { public static String sanitizeTag(final String tag) { if (StringUtils.isEmpty(tag)) { return null; } final String sanitized = JSONDB_DISALLOWED_KEY_CHARS.matcher(tag).replaceAll("").trim(); if (sanitized.length() > 768) { return sanitized.substring(0, Math.min(tag.length(), 768)); } return sanitized; } private  OasModelHelper(); static OperationDescription operationDescriptionOf(final OasDocument openApiDoc, final OasOperation operation,
                                                              final BiFunction<String, String, String> consumer); static List<OasPathItem> getPathItems(OasPaths paths); static List<OasParameter> getParameters(final OasOperation operation); static List<OasParameter> getParameters(final OasPathItem pathItem); static String sanitizeTag(final String tag); static Stream<String> sanitizeTags(final List<String> list); static Map<String, OasOperation> getOperationMap(OasPathItem pathItem); static Map<String, T> getOperationMap(OasPathItem pathItem, Class<T> type); static String getReferenceName(String reference); static boolean isArrayType(OasSchema schema); static boolean isReferenceType(OasSchema schema); static boolean isReferenceType(OasParameter parameter); static boolean isBody(OasParameter parameter); static String getPropertyName(OasSchema schema); static String getPropertyName(OasSchema schema, String defaultName); static boolean isSerializable(OasParameter parameter); static boolean schemaIsNotSpecified(final OasSchema schema); static URI specificationUriFrom(final OasDocument openApiDoc); static final String URL_EXTENSION; }