Skip to content

Commit

Permalink
Add docs on manually-provided schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Nov 9, 2023
1 parent 185b893 commit b3c662a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/endpoint/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
```eval_rst
.. note::
Note that the codecs defined by the tapir integrations are used only when the specific types (e.g. enumerations0 are
Note that the codecs defined by the tapir integrations are used only when the specific types (e.g. enumerations) are
used at the top level. Any nested usages (e.g. as part of a json body), need to be separately configured to work with
the used json library.
```
Expand Down
7 changes: 7 additions & 0 deletions doc/endpoint/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ implicit scope during codec derivation, as well as when using [json](json.md) or
Implicit schemas for basic types (`String`, `Int`, etc.), and their collections (`Option`, `List`, `Array` etc.) are
defined out-of-the box. They don't contain any meta-data, such as descriptions or example values.

There's also a number of [datatype integrations](integrations.md) available, which provide schemas for various
third-party libraries.

For case classes and sealed hierarchies, `Schema[_]` values can be derived automatically using
[Magnolia](https://github.com/softwaremill/magnolia), given that implicit schemas are available for all the case class's
fields, or all of the implementations of the `enum`/`sealed trait`/`sealed class`.
Expand All @@ -18,6 +21,10 @@ Two policies of custom type derivation are available:
* automatic derivation
* semi automatic derivation

Finally, schemas can be provided by hand, e.g. for Java classes, or other custom types. As a fallback, you can also
always use `Schema.string[T]` or `Schema.binary[T]`, however this will provide only basic documentation, and won't
perform any [validation](validation.md).

## Automatic derivation

Schemas for case classes, sealed traits and their children can be recursively derived. Importing `sttp.tapir.generic.auto._`
Expand Down

0 comments on commit b3c662a

Please sign in to comment.