Programmierpraktikum-MVA / AsyncAPI

πŸ”₯ Generates a blazingly fast ⚑️ microservice in Rust πŸ¦€, from an async API spec πŸ“„, that can effortlessly connect to message brokers πŸ“¨ and dynamically adapts to user-provided go-template files πŸ“ for a seamless ☁️ cloud-native experience. 🦾

Home Page:https://programmierpraktikum-mva.github.io/AsyncAPI/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crustagen

Crustagen is a Rust code generator that takes AsyncAPI specifications as input and generates Rust code along with all the required dependencies and auto-generated documentation. It's designed to be an efficient tool to convert AsyncAPI specs into Rust projects ready to build and run.

Build Status

Table of Contents

Requirements

  • Rust 1.70 or later.
  • Cargo (comes with Rust).

Installation

Clone and build the Crustagen project:

git clone https://github.com/Programmierpraktikum-MVA/AsyncAPI.git
cd AsyncAPI
just install # Alternatively, you can use 'cargo build --release'

Usage

To generate Rust code from an AsyncAPI specification, use the following just command:

just run example/specs/basic.yaml output # Alternatively, you can use 'cargo run -- -s ./example/specs/basic.yaml -o ./output'

This will generate a Rust project in the specified output directory.

To run the server, navigate to the output directory (replace {project-id} with the actual project directory name, the title of the spec) and use the just command:

just start-service {project-id} # Alternatively, you can use 'cd output/{project-id} && cargo run'

To view the auto-generated documentation, use the following command:

just service-doc {project-id} # Alternatively, you can use 'cd output/{project-id} && cargo doc --open'

Remember to replace {project-id} with the name of your generated microservice (title field from the provided spec).

Types

Rust types will be generated in the models folder according to the given payload json schema definitions. Names will be generated according to channels etc, if you want to share a payload type between two messages, make sure to use the same "name" property in the payload. Warning: This will not check if the types of those payloads are actually the same, so make sure to use the same schema or better even, simply a ref to the schema with the name. By default, all defined properties are required and no additional properties are allowed, if you want to use optional types, please modify the generated types after generation or use oneOf/anyOf/allOf to represent optional types.

Limitations

  • Only json payloads are currently supported for automatic deserialization
  • Only one server is currently supported and only nats protocol is supported
  • Generated microservice doesn't support authentication with NATS-broker out of the box
  • Only one message is currently supported per channel, payloads can be choosen freely including anyOf/oneOf/allOf
  • The generated rust types are required by default, if you want to use optional types, please modify the generated types after generation or use oneOf/anyOf/allOf to represent optional types
  • references in the specification are only suppported inside the same file, external references are not supported

Contribute

Contributions are always welcome! Please read the contribution guidelines first.

Authors

This project originated as a hands-on assignment for the MVA Praktikum course at the Technical University of Berlin. The initial authors and their corresponding GitHub profiles are listed below:

Name GitHub
Aiko Kipka @aikokal
Andreas Rother @andreas-rot
Felix Dumbeck @f-eliks
Jacob Große @jacobGr-afk
Niclas Doepner @doepnern
Ori Toledo Cohen @oritoledo
Stanislav Kosorin @stano45

License

This project is licensed under the MIT License. See the LICENSE file for more information.

About

πŸ”₯ Generates a blazingly fast ⚑️ microservice in Rust πŸ¦€, from an async API spec πŸ“„, that can effortlessly connect to message brokers πŸ“¨ and dynamically adapts to user-provided go-template files πŸ“ for a seamless ☁️ cloud-native experience. 🦾

https://programmierpraktikum-mva.github.io/AsyncAPI/

License:MIT License


Languages

Language:Rust 88.6%Language:Go 10.8%Language:Just 0.7%