Search in sources :

Example 51 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure by palantir.

the class Conjure method parse.

/**
 * Deserializes {@link ConjureDefinition} from their YAML representations in the given files.
 */
public static ConjureDefinition parse(Collection<File> files) {
    Map<String, AnnotatedConjureSourceFile> sourceFiles = ConjureParser.parseAnnotated(files);
    ConjureDefinition ir = ConjureParserUtils.parseConjureDef(sourceFiles);
    return NormalizeDefinition.normalize(ir);
}
Also used : AnnotatedConjureSourceFile(com.palantir.conjure.parser.AnnotatedConjureSourceFile) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition)

Example 52 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure-java by palantir.

the class AsyncRequestProcessingTest method beforeClass.

@BeforeAll
public static void beforeClass() throws IOException {
    ConjureDefinition def = Conjure.parse(ImmutableList.of(new File("src/test/resources/async-request-processing-test.yml")));
    List<Path> files = new GenerationCoordinator(MoreExecutors.directExecutor(), ImmutableSet.of(new UndertowServiceGenerator(Options.builder().undertowServicePrefix(true).undertowListenableFutures(true).build()), new JerseyServiceGenerator(Options.empty()))).emit(def, folder);
    validateGeneratorOutput(files, Paths.get("src/integrationInput/java/com/palantir/product"));
}
Also used : Path(java.nio.file.Path) JerseyServiceGenerator(com.palantir.conjure.java.services.JerseyServiceGenerator) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File) UndertowServiceGenerator(com.palantir.conjure.java.services.UndertowServiceGenerator) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 53 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure-java by palantir.

the class DialogueServiceGeneratorTests method testConjureImports.

@Test
public void testConjureImports() throws IOException {
    ConjureDefinition conjure = Conjure.parse(ImmutableList.of(new File("src/test/resources/example-conjure-imports.yml"), new File("src/test/resources/example-types.yml"), new File("src/test/resources/example-service.yml")));
    File src = Files.createDirectory(folder.toPath().resolve("src")).toFile();
    new GenerationCoordinator(MoreExecutors.directExecutor(), ImmutableSet.of(new DialogueServiceGenerator(Options.empty()))).emit(conjure, src);
    // Generated files contain imports
    assertThat(compiledFileContent(src, "test/api/with/imports/ImportServiceBlocking.java")).contains("import com.palantir.product.StringExample;");
}
Also used : ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File) DialogueServiceGenerator(com.palantir.conjure.java.services.dialogue.DialogueServiceGenerator) Test(org.junit.jupiter.api.Test)

Example 54 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure-java by palantir.

the class JerseyServiceGeneratorTests method testServiceGeneration.

private void testServiceGeneration(String conjureFile) throws IOException {
    ConjureDefinition def = Conjure.parse(ImmutableList.of(new File("src/test/resources/" + conjureFile + ".yml")));
    List<Path> files = new GenerationCoordinator(MoreExecutors.directExecutor(), ImmutableSet.of(new JerseyServiceGenerator(Options.builder().requireNotNullAuthAndBodyParams(true).build()))).emit(def, folder);
    validateGeneratorOutput(files, Paths.get("src/test/resources/test/api"), ".jersey");
}
Also used : Path(java.nio.file.Path) JerseyServiceGenerator(com.palantir.conjure.java.services.JerseyServiceGenerator) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File)

Example 55 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure-java by palantir.

the class JerseyServiceGeneratorTests method testBinaryReturnResponse.

@Test
public void testBinaryReturnResponse() throws IOException {
    ConjureDefinition def = Conjure.parse(ImmutableList.of(new File("src/test/resources/example-binary.yml")));
    List<Path> files = new GenerationCoordinator(MoreExecutors.directExecutor(), ImmutableSet.of(new JerseyServiceGenerator(Options.builder().jerseyBinaryAsResponse(true).build()))).emit(def, folder);
    validateGeneratorOutput(files, Paths.get("src/test/resources/test/api"), ".jersey.binary_as_response");
}
Also used : Path(java.nio.file.Path) JerseyServiceGenerator(com.palantir.conjure.java.services.JerseyServiceGenerator) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

ConjureDefinition (com.palantir.conjure.spec.ConjureDefinition)65 Test (org.junit.jupiter.api.Test)49 File (java.io.File)40 Path (java.nio.file.Path)30 ConjureIllegalStateException (com.palantir.conjure.exceptions.ConjureIllegalStateException)13 JerseyServiceGenerator (com.palantir.conjure.java.services.JerseyServiceGenerator)9 UndertowServiceGenerator (com.palantir.conjure.java.services.UndertowServiceGenerator)9 GenerationCoordinator (com.palantir.conjure.java.GenerationCoordinator)8 Retrofit2ServiceGenerator (com.palantir.conjure.java.services.Retrofit2ServiceGenerator)4 DialogueServiceGenerator (com.palantir.conjure.java.services.dialogue.DialogueServiceGenerator)4 AnnotatedConjureSourceFile (com.palantir.conjure.parser.AnnotatedConjureSourceFile)4 TypeDefinition (com.palantir.conjure.spec.TypeDefinition)4 BeforeAll (org.junit.jupiter.api.BeforeAll)4 TypeName (com.palantir.conjure.spec.TypeName)3 ImmutableList (com.google.common.collect.ImmutableList)2 ReferenceTypeResolver (com.palantir.conjure.defs.ConjureTypeParserVisitor.ReferenceTypeResolver)2 ConjureRuntimeException (com.palantir.conjure.exceptions.ConjureRuntimeException)2 ConjureSourceFile (com.palantir.conjure.parser.ConjureSourceFile)2 DefaultPostmanCollectionFileWriter (com.palantir.conjure.postman.writer.DefaultPostmanCollectionFileWriter)2 PostmanCollectionFileWriter (com.palantir.conjure.postman.writer.PostmanCollectionFileWriter)2