@Test public void testComputeDefinitionName() throws Exception { doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("http: doComputeDefinitionNameTestCase("./path/to/file.json", "file"); doComputeDefinitionNameTestCase("./path/to/file.json#/foo", "foo"); doComputeDefinitionNameTestCase("./path/to/file.json#/foo/bar", "bar"); doComputeDefinitionNameTestCase("./path/to/file.json#/foo/bar/hello", "hello"); doComputeDefinitionNameTestCase("./path/to/file.yaml", "file"); doComputeDefinitionNameTestCase("./path/to/file.yaml#/foo", "foo"); doComputeDefinitionNameTestCase("./path/to/file.yaml#/foo/bar", "bar"); doComputeDefinitionNameTestCase("./path/to/file.yaml#/foo/bar/hello", "hello"); doComputeDefinitionNameTestCase("./path/to/file", "file"); doComputeDefinitionNameTestCase("./path/to/file#/foo", "foo"); doComputeDefinitionNameTestCase("./path/to/file#/foo/bar", "bar"); doComputeDefinitionNameTestCase("./path/to/file#/foo/bar/hello", "hello"); }
public static String computeDefinitionName(String ref) { final String[] refParts = ref.split(REFERENCE_SEPARATOR); if (refParts.length > 2) { throw new RuntimeException("Invalid ref format: " + ref); } final String file = refParts[0]; final String definitionPath = refParts.length == 2 ? refParts[1] : null; String plausibleName; if (definitionPath != null) { final String[] jsonPathElements = definitionPath.split("/"); plausibleName = jsonPathElements[jsonPathElements.length - 1]; } else { final String[] filePathElements = file.split("/"); plausibleName = filePathElements[filePathElements.length - 1]; final String[] split = plausibleName.split("\\."); plausibleName = split[0]; } return plausibleName; }
RefUtils { public static String computeDefinitionName(String ref) { final String[] refParts = ref.split(REFERENCE_SEPARATOR); if (refParts.length > 2) { throw new RuntimeException("Invalid ref format: " + ref); } final String file = refParts[0]; final String definitionPath = refParts.length == 2 ? refParts[1] : null; String plausibleName; if (definitionPath != null) { final String[] jsonPathElements = definitionPath.split("/"); plausibleName = jsonPathElements[jsonPathElements.length - 1]; } else { final String[] filePathElements = file.split("/"); plausibleName = filePathElements[filePathElements.length - 1]; final String[] split = plausibleName.split("\\."); plausibleName = split[0]; } return plausibleName; } }
RefUtils { public static String computeDefinitionName(String ref) { final String[] refParts = ref.split(REFERENCE_SEPARATOR); if (refParts.length > 2) { throw new RuntimeException("Invalid ref format: " + ref); } final String file = refParts[0]; final String definitionPath = refParts.length == 2 ? refParts[1] : null; String plausibleName; if (definitionPath != null) { final String[] jsonPathElements = definitionPath.split("/"); plausibleName = jsonPathElements[jsonPathElements.length - 1]; } else { final String[] filePathElements = file.split("/"); plausibleName = filePathElements[filePathElements.length - 1]; final String[] split = plausibleName.split("\\."); plausibleName = split[0]; } return plausibleName; } private  RefUtils(); }
RefUtils { public static String computeDefinitionName(String ref) { final String[] refParts = ref.split(REFERENCE_SEPARATOR); if (refParts.length > 2) { throw new RuntimeException("Invalid ref format: " + ref); } final String file = refParts[0]; final String definitionPath = refParts.length == 2 ? refParts[1] : null; String plausibleName; if (definitionPath != null) { final String[] jsonPathElements = definitionPath.split("/"); plausibleName = jsonPathElements[jsonPathElements.length - 1]; } else { final String[] filePathElements = file.split("/"); plausibleName = filePathElements[filePathElements.length - 1]; final String[] split = plausibleName.split("\\."); plausibleName = split[0]; } return plausibleName; } private  RefUtils(); static String computeDefinitionName(String ref); static Optional<String> getExternalPath(String ref); static boolean isAnExternalRefFormat(RefFormat refFormat); static RefFormat computeRefFormat(String ref); static String mungedRef(String refString); static String readExternalUrlRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                            String rootPath); static String readExternalClasspathRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                                  String rootPath); static String buildUrl(String rootPath, String relativePath); static String readExternalRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                         Path parentDirectory); }
RefUtils { public static String computeDefinitionName(String ref) { final String[] refParts = ref.split(REFERENCE_SEPARATOR); if (refParts.length > 2) { throw new RuntimeException("Invalid ref format: " + ref); } final String file = refParts[0]; final String definitionPath = refParts.length == 2 ? refParts[1] : null; String plausibleName; if (definitionPath != null) { final String[] jsonPathElements = definitionPath.split("/"); plausibleName = jsonPathElements[jsonPathElements.length - 1]; } else { final String[] filePathElements = file.split("/"); plausibleName = filePathElements[filePathElements.length - 1]; final String[] split = plausibleName.split("\\."); plausibleName = split[0]; } return plausibleName; } private  RefUtils(); static String computeDefinitionName(String ref); static Optional<String> getExternalPath(String ref); static boolean isAnExternalRefFormat(RefFormat refFormat); static RefFormat computeRefFormat(String ref); static String mungedRef(String refString); static String readExternalUrlRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                            String rootPath); static String readExternalClasspathRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                                  String rootPath); static String buildUrl(String rootPath, String relativePath); static String readExternalRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                         Path parentDirectory);  }