congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
com.palantir.conjure.spec
Code IndexAdd Tabnine to your IDE (free)

How to use com.palantir.conjure.spec

Best Java code snippets using com.palantir.conjure.spec (Showing top 20 results out of 315)

origin: com.palantir.conjure/conjure-generator-common

  @Override
  public Boolean visitPrimitive(PrimitiveType value) {
    return value.get() == PrimitiveType.Value.BINARY;
  }
}
origin: palantir/conjure

/**
 * Inlines outer-level aliases and references, but not within objects or container types.
 * <p>
 * For example, a reference to an alias A which wraps another alias B which wraps a {@code list<integer>}, we'll
 * return {@code list<integer>}. Note that these are outer-level references being resolved.
 * However, if the aforementioned list's inner type was also a reference e.g. {@code list<C>}, we
 * wouldn't unwrap that, so we'd just return the same {@code list<C>}.
 */
public Either<TypeDefinition, Type> dealias(Type type) {
  return type.accept(this);
}
origin: palantir/conjure

  @Override
  public TypeName visitExternal(ExternalReference value) {
    return value.getExternalReference();
  }
}
origin: palantir/conjure

  private EndpointDefinition.Builder createEndpoint(String paramName) {
    ArgumentDefinition arg = ArgumentDefinition.builder()
        .paramType(ParameterType.body(BodyParameterType.of()))
        .type(Type.primitive(PrimitiveType.STRING))
        .argName(ArgumentName.of(paramName))
        .build();
    return EndpointDefinition.builder()
        .httpMethod(HttpMethod.POST)
        .httpPath(HttpPath.of("/a/path"))
        .args(ImmutableList.of(arg))
        .endpointName(EndpointName.of("test"));
  }
}
origin: palantir/conjure

  private EndpointDefinition createEndpoint(ParameterType paramType) {
    ArgumentDefinition arg = ArgumentDefinition.builder()
        .argName(PARAMETER_NAME)
        .paramType(paramType)
        .type(Type.primitive(PrimitiveType.INTEGER))
        .build();
    EndpointDefinition definition = EndpointDefinition.builder()
        .httpMethod(HttpMethod.POST)
        .httpPath(HttpPath.of("/a/path"))
        .args(arg)
        .endpointName(EndpointName.of("test"))
        .build();

    EndpointDefinitionValidator.validateAll(definition, dealiasingVisitor);
    return definition;
  }
}
origin: palantir/conjure

@Test
public void testUnionMemberKeyMustNotBeEmpty() {
  FieldDefinition fieldDefinition = FieldDefinition.builder()
      .fieldName(FieldName.of(""))
      .type(Type.primitive(PrimitiveType.STRING))
      .build();
  assertThatThrownBy(() ->
      UnionDefinitionValidator.validateAll(UnionDefinition.builder()
          .union(fieldDefinition)
          .typeName(TypeName.of("string", ""))
          .build()))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessageStartingWith("Union member key must not be empty");
}
origin: palantir/conjure

@Test
public void testSingleBodyParamValidator() {
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .args(BODY_ARG_BUILDER.argName(ArgumentName.of("bodyArg1")).build())
      .args(BODY_ARG_BUILDER.argName(ArgumentName.of("bodyArg2")).build())
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.GET)
      .httpPath(HttpPath.of("/a/path"));
  assertThatThrownBy(() -> EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor))
      .isInstanceOf(IllegalStateException.class)
      .hasMessage("Endpoint cannot have multiple body parameters: [bodyArg1, bodyArg2]");
}
origin: palantir/conjure

private static Optional<TypeName> resolveReferenceType(Type type) {
  if (type.accept(TypeVisitor.IS_REFERENCE)) {
    return Optional.of(type.accept(TypeVisitor.REFERENCE));
  } else if (type.accept(TypeVisitor.IS_PRIMITIVE)) {
    return Optional.of(
        TypeName.of(type.accept(TypeVisitor.PRIMITIVE).get().name(), ""));
  }
  return Optional.empty();
}
origin: palantir/conjure

  private static void checkForComplexType(FieldDefinition typeDef) {
    if (typeDef.getType().accept(TypeVisitor.IS_MAP)) {
      MapType mapType = typeDef.getType().accept(TypeVisitor.MAP);
      if (!mapType.getKeyType().accept(TypeVisitor.IS_PRIMITIVE_OR_REFERENCE)) {
        throw new IllegalStateException(
            String.format("Complex type '%s' not allowed in map key: %s.",
                mapType.getKeyType(), typeDef));
      }
    }
  }
}
origin: palantir/conjure

  private FieldDefinition field(FieldName name, String type) {
    return FieldDefinition.of(name, Type.reference(TypeName.of(type, PACKAGE)), DOCS);
  }
}
origin: palantir/conjure

@Override
public Type visitAny(AnyType type) {
  return Type.primitive(com.palantir.conjure.spec.PrimitiveType.ANY);
}
origin: com.palantir.conjure/conjure-generator-common

@Override
public TypeName visitUnion(UnionDefinition value) {
  return value.getTypeName();
}
origin: palantir/conjure

@Override
public TypeName visitEnum(EnumDefinition value) {
  return value.getTypeName();
}
origin: palantir/conjure

@Test
@SuppressWarnings("CheckReturnValue")
public void testArgumentBodyTypeValidator() {
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .args(ImmutableList.of(ArgumentDefinition.builder()
          .argName(ArgumentName.of("testArg"))
          .type(Type.primitive(PrimitiveType.BINARY))
          .paramType(ParameterType.body(BodyParameterType.of()))
          .build()))
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.POST)
      .httpPath(HttpPath.of("/a/path"));
  // Should not throw exception
  EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor);
}
origin: palantir/conjure

  @Override
  public Boolean visitPrimitive(PrimitiveType value) {
    return value.get() == PrimitiveType.Value.BINARY;
  }
}
origin: palantir/conjure

  @Override
  public Type visitDateTime(DateTimeType type) {
    return Type.primitive(com.palantir.conjure.spec.PrimitiveType.DATETIME);
  }
}
origin: com.palantir.conjure/conjure-generator-common

/**
 * Inlines outer-level aliases and references, but not within objects or container types.
 * <p>
 * For example, a reference to an alias A which wraps another alias B which wraps a {@code list<integer>}, we'll
 * return {@code list<integer>}. Note that these are outer-level references being resolved.
 * However, if the aforementioned list's inner type was also a reference e.g. {@code list<C>}, we
 * wouldn't unwrap that, so we'd just return the same {@code list<C>}.
 */
public Either<TypeDefinition, Type> dealias(Type type) {
  return type.accept(this);
}
origin: com.palantir.conjure/conjure-generator-common

  @Override
  public TypeName visitExternal(ExternalReference value) {
    return value.getExternalReference();
  }
}
origin: com.palantir.conjure/conjure-generator-common

  @Override
  public Boolean visitPrimitive(PrimitiveType value) {
    return value.get() == PrimitiveType.Value.ANY;
  }
}
origin: palantir/conjure

  @Override
  public Boolean visitPrimitive(PrimitiveType value) {
    return value.get() == PrimitiveType.Value.ANY;
  }
}
com.palantir.conjure.spec

Most used classes

  • EnumDefinition
  • ObjectDefinition
  • Type
  • TypeDefinition
  • UnionDefinition
  • ExternalReference,
  • PrimitiveType,
  • ArgumentDefinition$Builder,
  • ArgumentDefinition,
  • ArgumentName,
  • BodyParameterType,
  • ConjureDefinition$Builder,
  • ConjureDefinition,
  • EndpointDefinition$Builder,
  • EndpointDefinition,
  • EndpointName,
  • EnumDefinition$Builder,
  • EnumValueDefinition$Builder,
  • EnumValueDefinition
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now