Search in sources :

Example 1 with Documentation

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);
}
Also used : Documentation(com.palantir.conjure.spec.Documentation) ObjectDefinition(com.palantir.conjure.spec.ObjectDefinition)

Example 2 with Documentation

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;
}
Also used : EnumValueDefinition(com.palantir.conjure.spec.EnumValueDefinition) Documentation(com.palantir.conjure.spec.Documentation)

Example 3 with Documentation

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();
}
Also used : BodyParameterType(com.palantir.conjure.spec.BodyParameterType) ParameterType(com.palantir.conjure.spec.ParameterType) PathParameterType(com.palantir.conjure.spec.PathParameterType) QueryParameterType(com.palantir.conjure.spec.QueryParameterType) HeaderParameterType(com.palantir.conjure.spec.HeaderParameterType) ImmutableList(com.google.common.collect.ImmutableList) Documentation(com.palantir.conjure.spec.Documentation) ArgumentDefinition(com.palantir.conjure.spec.ArgumentDefinition) ParameterName(com.palantir.conjure.parser.services.ParameterName) Map(java.util.Map) HashMap(java.util.HashMap) ArgumentName(com.palantir.conjure.spec.ArgumentName)

Example 4 with Documentation

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;
}
Also used : HeaderAuthType(com.palantir.conjure.spec.HeaderAuthType) PathString(com.palantir.conjure.parser.services.PathString) SafeIllegalStateException(com.palantir.logsafe.exceptions.SafeIllegalStateException) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) ServiceDefinitionValidator(com.palantir.conjure.defs.validator.ServiceDefinitionValidator) ServiceDefinition(com.palantir.conjure.spec.ServiceDefinition) EnumValueDefinitionValidator(com.palantir.conjure.defs.validator.EnumValueDefinitionValidator) ConjureDefinitionValidator(com.palantir.conjure.defs.validator.ConjureDefinitionValidator) NamedTypesDefinition(com.palantir.conjure.parser.types.NamedTypesDefinition) Map(java.util.Map) ObjectDefinitionValidator(com.palantir.conjure.defs.validator.ObjectDefinitionValidator) ArgumentName(com.palantir.conjure.spec.ArgumentName) AnnotatedConjureSourceFile(com.palantir.conjure.parser.AnnotatedConjureSourceFile) ParameterId(com.palantir.conjure.spec.ParameterId) EndpointDefinitionValidator(com.palantir.conjure.defs.validator.EndpointDefinitionValidator) LogSafetyDefinition(com.palantir.conjure.parser.LogSafetyDefinition) ObjectDefinition(com.palantir.conjure.spec.ObjectDefinition) ConjureImports(com.palantir.conjure.parser.types.reference.ConjureImports) AuthType(com.palantir.conjure.spec.AuthType) Collection(java.util.Collection) SafeIllegalArgumentException(com.palantir.logsafe.exceptions.SafeIllegalArgumentException) Set(java.util.Set) BodyParameterType(com.palantir.conjure.spec.BodyParameterType) FieldDefinition(com.palantir.conjure.spec.FieldDefinition) Collectors(java.util.stream.Collectors) FieldDefinitionValidator(com.palantir.conjure.defs.validator.FieldDefinitionValidator) ParameterType(com.palantir.conjure.spec.ParameterType) List(java.util.List) AliasDefinition(com.palantir.conjure.spec.AliasDefinition) UnsafeArg(com.palantir.logsafe.UnsafeArg) ReferenceTypeResolver(com.palantir.conjure.defs.ConjureTypeParserVisitor.ReferenceTypeResolver) Documentation(com.palantir.conjure.spec.Documentation) ConjureRuntimeException(com.palantir.conjure.exceptions.ConjureRuntimeException) Optional(java.util.Optional) HttpPathValidator(com.palantir.conjure.defs.validator.HttpPathValidator) PrimitiveType(com.palantir.conjure.spec.PrimitiveType) EndpointDefinition(com.palantir.conjure.spec.EndpointDefinition) HttpMethod(com.palantir.conjure.spec.HttpMethod) LogSafety(com.palantir.conjure.spec.LogSafety) EnumDefinitionValidator(com.palantir.conjure.defs.validator.EnumDefinitionValidator) FieldNameValidator(com.palantir.conjure.defs.validator.FieldNameValidator) ErrorDefinition(com.palantir.conjure.spec.ErrorDefinition) Type(com.palantir.conjure.spec.Type) PathParameterType(com.palantir.conjure.spec.PathParameterType) TypeDefinitionVisitor(com.palantir.conjure.visitor.TypeDefinitionVisitor) HashMap(java.util.HashMap) Namespace(com.palantir.conjure.parser.types.names.Namespace) HttpPath(com.palantir.conjure.spec.HttpPath) ConjureIllegalArgumentException(com.palantir.conjure.exceptions.ConjureIllegalArgumentException) Function(java.util.function.Function) ArrayList(java.util.ArrayList) UnionDefinition(com.palantir.conjure.spec.UnionDefinition) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) ErrorNamespace(com.palantir.conjure.spec.ErrorNamespace) TypeNameValidator(com.palantir.conjure.defs.validator.TypeNameValidator) PackageValidator(com.palantir.conjure.defs.validator.PackageValidator) TypeDefinition(com.palantir.conjure.spec.TypeDefinition) EnumDefinition(com.palantir.conjure.spec.EnumDefinition) CookieAuthType(com.palantir.conjure.spec.CookieAuthType) EnumValueDefinition(com.palantir.conjure.spec.EnumValueDefinition) ErrorDefinitionValidator(com.palantir.conjure.defs.validator.ErrorDefinitionValidator) ParameterName(com.palantir.conjure.parser.services.ParameterName) EndpointName(com.palantir.conjure.spec.EndpointName) QueryParameterType(com.palantir.conjure.spec.QueryParameterType) TypeName(com.palantir.conjure.spec.TypeName) FieldName(com.palantir.conjure.spec.FieldName) ConjureSourceFile(com.palantir.conjure.parser.ConjureSourceFile) DealiasingTypeVisitor(com.palantir.conjure.visitor.DealiasingTypeVisitor) ConjurePackage(com.palantir.conjure.parser.types.names.ConjurePackage) UnionDefinitionValidator(com.palantir.conjure.defs.validator.UnionDefinitionValidator) HeaderParameterType(com.palantir.conjure.spec.HeaderParameterType) Preconditions(com.palantir.logsafe.Preconditions) ArgumentDefinition(com.palantir.conjure.spec.ArgumentDefinition) HttpPath(com.palantir.conjure.spec.HttpPath) Documentation(com.palantir.conjure.spec.Documentation) EndpointDefinition(com.palantir.conjure.spec.EndpointDefinition)

Example 5 with Documentation

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;
}
Also used : ErrorDefinition(com.palantir.conjure.spec.ErrorDefinition) Documentation(com.palantir.conjure.spec.Documentation)

Aggregations

Documentation (com.palantir.conjure.spec.Documentation)7 ImmutableList (com.google.common.collect.ImmutableList)2 ParameterName (com.palantir.conjure.parser.services.ParameterName)2 ArgumentDefinition (com.palantir.conjure.spec.ArgumentDefinition)2 ArgumentName (com.palantir.conjure.spec.ArgumentName)2 BodyParameterType (com.palantir.conjure.spec.BodyParameterType)2 EnumValueDefinition (com.palantir.conjure.spec.EnumValueDefinition)2 HeaderParameterType (com.palantir.conjure.spec.HeaderParameterType)2 ObjectDefinition (com.palantir.conjure.spec.ObjectDefinition)2 ParameterType (com.palantir.conjure.spec.ParameterType)2 PathParameterType (com.palantir.conjure.spec.PathParameterType)2 QueryParameterType (com.palantir.conjure.spec.QueryParameterType)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ReferenceTypeResolver (com.palantir.conjure.defs.ConjureTypeParserVisitor.ReferenceTypeResolver)1 ConjureDefinitionValidator (com.palantir.conjure.defs.validator.ConjureDefinitionValidator)1 EndpointDefinitionValidator (com.palantir.conjure.defs.validator.EndpointDefinitionValidator)1 EnumDefinitionValidator (com.palantir.conjure.defs.validator.EnumDefinitionValidator)1 EnumValueDefinitionValidator (com.palantir.conjure.defs.validator.EnumValueDefinitionValidator)1 ErrorDefinitionValidator (com.palantir.conjure.defs.validator.ErrorDefinitionValidator)1