use of com.palantir.conjure.spec.Documentation in project conjure by palantir.
the class ConjureParserUtils method parseObjectType.
public static TypeDefinition parseObjectType(TypeName name, com.palantir.conjure.parser.types.complex.ObjectTypeDefinition def, ConjureTypeParserVisitor.ReferenceTypeResolver typeResolver) {
ObjectDefinition objectType = ObjectDefinition.builder().typeName(name).fields(parseField(def.fields(), typeResolver)).docs(def.docs().map(Documentation::of)).build();
ObjectDefinitionValidator.validate(objectType);
return TypeDefinition.object(objectType);
}
use of com.palantir.conjure.spec.Documentation in project conjure by palantir.
the class ConjureParserUtils method parseEnumValue.
private static EnumValueDefinition parseEnumValue(com.palantir.conjure.parser.types.complex.EnumValueDefinition def) {
EnumValueDefinition enumValue = EnumValueDefinition.builder().value(def.value()).docs(def.docs().map(Documentation::of)).deprecated(def.deprecated().map(Documentation::of)).build();
EnumValueDefinitionValidator.validateAll(enumValue);
return enumValue;
}
use of com.palantir.conjure.spec.Documentation in project conjure by palantir.
the class ConjureParserUtils method parseArgs.
private static List<ArgumentDefinition> parseArgs(Map<ParameterName, com.palantir.conjure.parser.services.ArgumentDefinition> args, HttpPath httpPath, ReferenceTypeResolver typeResolver) {
ImmutableList.Builder<ArgumentDefinition> resultBuilder = ImmutableList.builder();
for (Map.Entry<ParameterName, com.palantir.conjure.parser.services.ArgumentDefinition> entry : args.entrySet()) {
com.palantir.conjure.parser.services.ArgumentDefinition original = entry.getValue();
ArgumentName argName = ArgumentName.of(entry.getKey().name());
ParameterType paramType = parseParameterType(original, argName, httpPath);
ArgumentDefinition.Builder builder = ArgumentDefinition.builder().argName(argName).type(original.type().visit(new ConjureTypeParserVisitor(typeResolver))).paramType(paramType).docs(original.docs().map(Documentation::of)).safety(original.safety().map(ConjureParserUtils::parseLogSafety)).markers(parseMarkers(original.markers(), typeResolver)).tags(original.tags().stream().peek(tag -> Preconditions.checkArgument(!tag.isEmpty(), "tag must not be empty")).collect(Collectors.toSet()));
resultBuilder.add(builder.build());
}
return resultBuilder.build();
}
use of com.palantir.conjure.spec.Documentation 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;
}
use of com.palantir.conjure.spec.Documentation in project conjure by palantir.
the class ConjureParserUtils method parseErrorType.
public static ErrorDefinition parseErrorType(TypeName name, com.palantir.conjure.parser.types.complex.ErrorTypeDefinition def, ConjureTypeParserVisitor.ReferenceTypeResolver typeResolver) {
ErrorDefinition errorType = ErrorDefinition.builder().errorName(name).namespace(ErrorNamespace.of(def.namespace().name())).code(def.code().asSpecErrorCode()).safeArgs(parseField(def.safeArgs(), typeResolver)).unsafeArgs(parseField(def.unsafeArgs(), typeResolver)).docs(def.docs().map(Documentation::of)).build();
ErrorDefinitionValidator.validate(errorType);
return errorType;
}
Aggregations