Swiftpack.co -  Package - amzn/smoke-framework-application-generate
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
amzn/smoke-framework-application-generate
Code generator to generate SmokeFramework-based applications from service models.
.package(url: "https://github.com/amzn/smoke-framework-application-generate.git", from: "2.3.0")

Build - Master Branch Swift 5.1, 5.2 and 5.3 Tested Ubuntu 16.04, 18.04 and 20.04 Tested CentOS 8 Tested Amazon Linux 2 Tested Join the Smoke Server Side community on gitter Apache 2

SmokeFrameworkApplicationGenerate

Code generator to generate SmokeFramework-based applications from service models.

Generate a SmokeFramework application package from a Swagger 2.0 specification file

Step 1: Check out this repository

Clone this repository to your local machine.

Step 2: Create a new directory in which to create your service.

You will point this code generator to this directory to output the generated code.

Step 3: Create a model describing your service using Swagger 2.0

Follow the Swagger specification to create an API specification for your service.

Step 4: Run the code generator

From within your checked out copy of this repository, run this command-

swift run -c release SmokeFrameworkApplicationGenerate \
  --base-file-path <the path to where you want the service to be generated> \
  --base-name <a base name for your service (without the "Service" postfix)> \
  --model-path <the path to the Swagger model you created> \
  --generation-type [server: to generate a new service|serverUpdate: to preserve changes to existing operation handlers]
 [--model-override-path <optionally the path to a json file that specifies various overrides to the model>]

And example command would look like this-

swift run -c release SmokeFrameworkApplicationGenerate \
  --base-file-path /Volumes/Workspace/smoke-framework-examples/PersistenceExampleService \
  --base-name PersistenceExample \
  --model-path /Volumes/Workspace/smoke-framework-examples/PersistenceExampleService/Swagger.yaml \
  --generation-type server \
  --model-override-path /Volumes/Workspace/smoke-framework-examples/PersistenceExampleService/modelOverride.json

An example service based on the command above can be found here.

Step 5: Modify the stubbed service generated

The code generator will produce a Swift Package Manager repository with the following directory structure-

- Package.swift
- .swiftlint
- .gitignore
- Sources
  - (base-name)Client
  - (base-name)Model
  - (base-name)Operations
  - (base-name)OperationsHTTP1
  - (base-name)Service
- Tests
  - LinuxMain.swift      
  - <base-name>OperationsTests

The following three sections of the repository provides initial stubs and can be filled out as required for the service.
A generation-type of serverUpdate will not overwrite changes in these sections-

  • (base-name)Operations: Stub implementations for each operation; should be modified to fullfill the services's logic.
  • (base-name)OperationsTests: Stub test implementations for each operation; should be modified to test the services's logic.
  • (base-name)Service: Operations context initialization and shutdown code; should be modified to create the context for the current environment.

The following three section contain code generated code to help the service operate but should not be manually modified. A generation-type of serverUpdate will overwrite changes in these sections-

  • (base-name)Client: APIGateway and mock clients for the service; should not be manually modified.
  • (base-name)Client: Input and output structures and types for the service; should not be manually modified.
  • (base-name)Client: Operation selection and input/output type handling specific to HTTP1; should not be manually modified.

License

This library is licensed under the Apache 2.0 License.

GitHub

link
Stars: 15
Last commit: 2 days ago

Release Notes

Set optionalsInitializeEmpty to true for generated models.
15 weeks ago

This release of SmokeFrameworkApplicationGenerate provides compatibility with Swift 5.1, Swift 5.2 and Swift 5.3 using SwiftNIO 2.x and SmokeFramework 2.x.

  1. Set optionalsInitializeEmpty to true for generated models. (#15)

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco