use of com.palantir.conjure.defs.ConjureTypeParserVisitor.ReferenceTypeResolver in project conjure by palantir.
the class ConjureParserUtils method innerParseImportObjects.
private static Map<TypeName, TypeDefinition> innerParseImportObjects(Map<Namespace, ConjureImports> conjureImports, Map<String, AnnotatedConjureSourceFile> externalTypes, Set<String> loadedFiles) {
Map<TypeName, TypeDefinition> allDefinitions = new HashMap<>();
conjureImports.values().forEach(conjureImport -> {
String pathKey = conjureImport.absoluteFile().orElseThrow(() -> new SafeIllegalStateException("Absolute file MUST be resolved as part of parsing stage")).getAbsolutePath();
// These structures are potentially recursive; load in any given conjure file once
if (loadedFiles.contains(pathKey)) {
return;
}
loadedFiles.add(pathKey);
AnnotatedConjureSourceFile annotatedConjureSourceFile = externalTypes.get(pathKey);
Preconditions.checkNotNull(annotatedConjureSourceFile, "Couldn't find import", UnsafeArg.of("file", conjureImport.file()));
ConjureSourceFile conjureDef = annotatedConjureSourceFile.conjureSourceFile();
Map<Namespace, String> importProviders = annotatedConjureSourceFile.importProviders();
ReferenceTypeResolver importTypeResolver = new ConjureTypeParserVisitor.ByParsedRepresentationTypeNameResolver(conjureDef.types(), importProviders, externalTypes);
allDefinitions.putAll(parseObjects(conjureDef.types(), importTypeResolver));
allDefinitions.putAll(innerParseImportObjects(conjureDef.types().conjureImports(), externalTypes, loadedFiles));
});
return allDefinitions;
}
use of com.palantir.conjure.defs.ConjureTypeParserVisitor.ReferenceTypeResolver in project conjure by palantir.
the class ConjureParserUtils method parseEndpoint.
private static EndpointDefinition parseEndpoint(String name, com.palantir.conjure.parser.services.EndpointDefinition def, PathString basePath, Optional<AuthType> defaultAuth, ReferenceTypeResolver typeResolver, DealiasingTypeVisitor dealiasingVisitor) {
HttpPath httpPath = parseHttpPath(def, basePath);
EndpointDefinition endpoint = EndpointDefinition.builder().endpointName(EndpointName.of(name)).httpMethod(HttpMethod.valueOf(def.http().method())).httpPath(httpPath).auth(def.auth().map(ConjureParserUtils::parseAuthType).orElse(defaultAuth)).args(parseArgs(def.args(), httpPath, typeResolver)).tags(def.tags().stream().peek(tag -> Preconditions.checkArgument(!tag.isEmpty(), "tag must not be empty")).collect(Collectors.toSet())).markers(parseMarkers(def.markers(), typeResolver)).returns(def.returns().map(t -> t.visit(new ConjureTypeParserVisitor(typeResolver)))).docs(def.docs().map(Documentation::of)).deprecated(def.deprecated().map(Documentation::of)).build();
EndpointDefinitionValidator.validateAll(endpoint, dealiasingVisitor);
return endpoint;
}
Aggregations