Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ThijsBroersen committed Jun 14, 2024
1 parent b35baa6 commit 2fc1c70
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions doc/endpoint/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ val s: Schema[StringOrInt] = Schema.derivedUnion[StringOrInt]
If any of the components of the union type is a generic type, any of its validations will be skipped when validating
the union type, as it's not possible to generate a runtime check for the generic type.

### Derivation for string-based constant union types

If a union type is a string-based constant union type, it can be auto-derived as field type or manually derived by using the `Schema.derivedStringUnion[T]` method.

Examples:
```scala
val aOrB: Schema["a" | "b"] = Schema.derivedStringBasedUnionEnumeration
```
```scala
val a: Schema["a"] = Schema.constStringToEnum
```
```scala
case class Foo(aOrB: "a" | "b", optA: Option["a"]) derives Schema
```

## Configuring derivation

It is possible to configure Magnolia's automatic derivation to use `snake_case`, `kebab-case` or a custom field naming
Expand Down

0 comments on commit 2fc1c70

Please sign in to comment.