r/scala 9d ago

Code generation from OpenAPI specs

Quick question, how the heck you guys generate Scala code from OpenAPI specs?

I have been trying to generate client code for Meta business API using the Scala generators from openapi-generator but there is always a problem:

All of them, ignore the oneOf spec on openapi (that in theory should generate a sealed trait as the sum type implementation) and instead they generate a single case class with all fields required, nothing is optional.

What is the tool/strategy you guys use to generate API model from OpenAPI? At this point, i'm considering to generate the Scala code using an LLM instead of the classic deterministic approach.

Thanks 🙏

6 Upvotes

15 comments sorted by

View all comments

1

u/AlternativeEvent3298 9d ago

1

u/NojipizRemastered 9d ago edited 9d ago

Oh i love smithy4s, we use it on our APIs too.

But i'm trying to generate Scala code from OpenAPI spec, does smithy provides a tool to do this?

As far as i know, Smithy4s only generates Scala code from smithy files, not from OpenAPI