Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
noodlemind authored Aug 5, 2024
1 parent e203eb9 commit 902987f
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
# YAML to Kotlin Gradle Plugin
# YAML to Kotlin Gradle Plugin [![GitHub license](https://img.shields.io/github/license/noodlemind/yaml-to-kotlin)](https://github.com/noodlemind/yaml-to-kotlin/blob/main/LICENSE.md) [![Build Status](https://img.shields.io/github/workflow/status/noodlemind/yaml-to-kotlin/Build)](https://github.com/noodlemind/yaml-to-kotlin/actions) [![Gradle Plugin Portal](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fplugins.gradle.org%2Fm2%2Fio%2Fgithub%2Fnoodlemind%2Fyaml-to-kotlin%2Fmaven-metadata.xml&label=Plugin%20Portal)](https://plugins.gradle.org/plugin/io.github.noodlemind.yaml-to-kotlin)

This Gradle plugin generates Kotlin data classes from YAML schema definitions.
Tired of writing Kotlin data classes by hand? Let YAML do the heavy lifting! This Gradle plugin automatically generates type-safe Kotlin data classes, complete with validation, from your YAML schema definitions.

## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [YAML Schema Standards](#yaml-schema-standards)
- [Configuration Options](#configuration-options)
- [Examples](#examples)
- [Contributing](#contributing)
- [License](#license)
## Why YAML to Kotlin?

* Readability: YAML's clean syntax makes it easy to define complex data structures.
* Type Safety: Generated Kotlin data classes provide compile-time checks for data integrity.
* Less Boilerplate: Say goodbye to tedious, manual data class creation.
* Maintainability: Keep your data models in sync with your YAML schemas effortlessly.

## Key Features

* Effortless Data Modeling: Craft your data models in human-readable YAML.
* Automatic Code Generation: Generate Kotlin data classes with a single Gradle task.
* Basic Validation: Start with built-in validation rules, or add your own.
* Customization: Configure output directories, package names, and more.
* Future-Proof: Stay tuned for upcoming features like advanced validation and Kotlinx.serialization support!

## Installation

Add the following to your `build.gradle.kts` file:
## Installation
```kotlin
kotlin plugins { id("io.github.noodlemind.yaml-to-kotlin") version "1.0.0" }
plugins {
id("io.github.noodlemind.yaml-to-kotlin") version "1.0.0"
}

```


## Usage

1. Place your YAML schema files in the `src/main/resources/schemas` directory.
2. Configure the plugin in your `build.gradle.kts`:

```kotlin
kotlin yamlToKotlin { inputDir.set(file("src/main/resources/schemas")) outputDir.set(file("build/generated/source/yaml-to-kotlin")) packageName = "com.example.generated" }
```
kotlin yamlToKotlin { inputDir.set(file("src/main/resources/schemas")) outputDir.set(file("build/generated/source/yaml-to-kotlin")) packageName = "com.example.generated" }
```
3. Run the Gradle task:
```commandline
./gradlew generateKotlinFromYaml
```
```commandline
./gradlew generateKotlinFromYaml
```

## YAML Schema Standards

Expand All @@ -52,7 +60,7 @@ Your YAML schemas should follow these standards:
| `validations` | `name` | string | Name of the custom validation | Yes |
| `validations` | `params` | array of strings | Parameters for the custom validation | No |

For more detailed examples, see the [Examples](#examples) section.


## Configuration Options

Expand Down Expand Up @@ -109,7 +117,6 @@ validations:
- min
- max
- name: emailFormat

```
#### Department Data Class
Expand Down Expand Up @@ -141,13 +148,17 @@ entities:

validations:
- name: uniqueDepartmentName

```
## Contributing
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for more details.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
This project is licensed under  
the MIT License - see the [LICENSE](LICENSE.md) file for  
details.
Let's write cleaner, safer, and more maintainable Kotlin code together!

0 comments on commit 902987f

Please sign in to comment.