...

/

Refining the Generated Documentation: Part-II

Refining the Generated Documentation: Part-II

Learn how to refine the generated documentation manually and explore the documentation.

Update the pattern attribute in the documentation

Before you ask, we can update all parameters because we have only one.

Press + to interact
(paths composeLens at("/product/{id}") composeOptional possible
composeLens pathParams composeTraversal each composeOptional
possible composeLens parameterSchema composeOptional possible
composeLens schemaPattern)
.set(Option("Fancy UUID regex here!"))(docs)

It seems that we can check off the first point on our list.

Additional lenses for content schemas

We are left with modifying the pattern field of the actual model schemas. To get to these, we have to define some more lenses.

Press + to interact
val components: Lens[OpenAPI, Option[Components]] =
GenLens[OpenAPI](_.components)
//typeLens[Components, ListMap[String, OpenAPI.ReferenceOr[Schema]]]
val componentsSchemas =
GenLens[Components](_.schemas)
//typeLens[Schema,ListMap[String,OpenAPI.ReferenceOr[Schema]]]
val schemaProperties =
GenLens[Schema](_.properties)

The power of lenses allows us to traverse all of our structures and modify all affected models at once. So, we will use the functionality provided by the Each type class here. Let’s try something like the following code.

Press + to interact
(paths composeTraversal each composeLens getOps).getAll(docs)
Press + to interact
[error] ...: diverging implicit expansion for type cats.kernel.Order[A]
[error] starting with method catsKernelStdOrderForSortedSet in trait
LowPrioritySortedSetInstancesBinCompat1
[error] (paths composeTraversal each composeLens getOps).getAll(docs)
[error] ^

This looks ...

Access this course and 1400+ top-rated courses and projects.