Class Generation
java.lang.Object
com.arc_e_tect.gradle.apionly.transcriberj.core.Generation
One generation run: a contract in, a tree of Java sources out.
The core emitter runs first; then every other emitter, in the order given, over the same model and the same class names.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classWhatderive(java.nio.file.Path, java.nio.file.Path, java.lang.String, java.lang.String, com.arc_e_tect.gradle.apionly.transcriberj.spi.Settings)works out once: the model, the class names, the cases and the core's report, and the core's output, not yet written. -
Method Summary
Modifier and TypeMethodDescriptionstatic Generation.Derivationderive(Path contract, Path asyncContract, String contractVersion, String contractSha256, Settings settings) Derives everything the core generates from a contract -- the model, the class names, the invalid-request cases, the report -- and the core's own sources, held in memory.static GenerationReportrun(Path contract, String contractVersion, String contractSha256, Settings settings, Path outputDirectory, Path resourceDirectory, List<Emitter> emitters, Path endpointIndex) Generates one contract's sources, replacing whatever the output directory held.static GenerationReportrun(Path contract, Path asyncContract, String contractVersion, String contractSha256, Settings settings, Path outputDirectory, Path resourceDirectory, List<Emitter> emitters, Path endpointIndex) Generates one contract's sources from both of its documents.static GenerationReportrunEmitter(Generation.Derivation derivation, Emitter emitter, Path javaDirectory, Path resourceDirectory, Path filesDirectory) Runs one emitter over a derivation, replacing whatever its three directories held.static GenerationReportwriteCore(Generation.Derivation derivation, Path outputDirectory, Path resourceDirectory, Path endpointIndex) Writes the core's sources and resources, replacing whatever the two directories held, and the endpoint index.
-
Method Details
-
run
public static GenerationReport run(Path contract, String contractVersion, String contractSha256, Settings settings, Path outputDirectory, Path resourceDirectory, List<Emitter> emitters, Path endpointIndex) Generates one contract's sources, replacing whatever the output directory held.- Parameters:
contract- the fetched contract documentcontractVersion- the version the build locked the contract atcontractSha256- the SHA-256 the build locked the document atsettings- how the project asked for the classesoutputDirectory- where the sources goresourceDirectory- where a resource an emitter writes goesemitters- the emitters to run after the core emitterendpointIndex- where to write the path of every operation class and inline schema class, keyedClassName.PATH, for tools that read test sources without a classpath;nullto write none- Returns:
- what could not be generated in full
- Throws:
GenerationException- when no sources can be generated from the contract
-
run
public static GenerationReport run(Path contract, Path asyncContract, String contractVersion, String contractSha256, Settings settings, Path outputDirectory, Path resourceDirectory, List<Emitter> emitters, Path endpointIndex) Generates one contract's sources from both of its documents.They are read into one model, so a fragment both use -- a username in a response and in an event payload -- is one component, and one class.
- Parameters:
contract- the fetched OpenAPI documentasyncContract- the fetched AsyncAPI document, ornullwhen the contract has nonecontractVersion- the version the build locked the contract atcontractSha256- the SHA-256 the build locked the document atsettings- how the project asked for the classesoutputDirectory- where the sources goresourceDirectory- where a resource an emitter writes goesemitters- the emitters to run after the core emitterendpointIndex- where to write the path of every operation class and inline schema class, keyedClassName.PATH, for tools that read test sources without a classpath;nullto write none- Returns:
- what could not be generated in full
- Throws:
GenerationException- when no sources can be generated from the contract
-
derive
public static Generation.Derivation derive(Path contract, Path asyncContract, String contractVersion, String contractSha256, Settings settings) Derives everything the core generates from a contract -- the model, the class names, the invalid-request cases, the report -- and the core's own sources, held in memory. Nothing is written:writeCore(com.arc_e_tect.gradle.apionly.transcriberj.core.Generation.Derivation, java.nio.file.Path, java.nio.file.Path, java.nio.file.Path)writes the core's output, andrunEmitter(com.arc_e_tect.gradle.apionly.transcriberj.core.Generation.Derivation, com.arc_e_tect.gradle.apionly.transcriberj.spi.Emitter, java.nio.file.Path, java.nio.file.Path, java.nio.file.Path)runs one emitter over the same derivation.Every step is deterministic, so two derivations of one contract with one set of settings are the same, whichever task makes them.
- Parameters:
contract- the fetched OpenAPI documentasyncContract- the fetched AsyncAPI document, ornullwhen the contract has nonecontractVersion- the version the build locked the contract atcontractSha256- the SHA-256 the build locked the document atsettings- how the project asked for the classes- Returns:
- the derivation
- Throws:
GenerationException- when no sources can be generated from the contract
-
writeCore
public static GenerationReport writeCore(Generation.Derivation derivation, Path outputDirectory, Path resourceDirectory, Path endpointIndex) Writes the core's sources and resources, replacing whatever the two directories held, and the endpoint index.- Parameters:
derivation- the derivationoutputDirectory- where the core's sources goresourceDirectory- where the core's resources goendpointIndex- where the endpoint index goes;nullto write none- Returns:
- the core's report
-
runEmitter
public static GenerationReport runEmitter(Generation.Derivation derivation, Emitter emitter, Path javaDirectory, Path resourceDirectory, Path filesDirectory) Runs one emitter over a derivation, replacing whatever its three directories held.- Parameters:
derivation- the derivationemitter- the emitterjavaDirectory- where its Java sources goresourceDirectory- where its classpath resources gofilesDirectory- where its files go- Returns:
- what this emitter reported: the methods it degraded
-