How Can I Generate YAML, or X files from Spring Cloud Contract Contracts?

Spring Cloud Contract 带有一个 ToFileContractsTransformer 类,它让你可以将合约转储为给定 ContractConverter 的文件。它包含一个 static void main 方法,让你可以将转换器作为可执行文件运行。它采用以下参数:

Spring Cloud Contract comes with a ToFileContractsTransformer class that lets you dump contracts as files for the given ContractConverter. It contains a static void main method that lets you run the transformer as an executable. It takes the following arguments:

  • argument 1 : FQN: Fully qualified name of the ContractConverter (for example, PactContractConverter). REQUIRED.

  • argument 2 : path: Path where the dumped files should be stored. OPTIONAL — defaults to target/converted-contracts.

  • argument 3 : path: Path were the contracts should be searched for. OPTIONAL — defaults to src/test/resources/contracts.

在调用转换器后,将处理 Spring Cloud Contract 文件,并且根据所提供的 ContractTransformer 的完全限定名称,将合同转换为所需的格式并转储到提供的文件夹。

After calling the transformer, the Spring Cloud Contract files are processed and, depending on the provided FQN of the ContractTransformer, the contracts are transformed to the required format and dumped to the provided folder.