See article. Personal opinions:
- In my research, I’ve never found official OpenAPI documantation or any other non-official guides recommending handwriting OAS.
- Typically, there’s no benefit in handwriting the OpenAPI schema.
- Writing JSON or YAML is typically harder (especially in complex scenarios) compared to writing in C#: Creating a stub Controller (i.e. return
501 Not Implemented
or200 OK
, or disable it with a feature flag which returns404
by default) with the request & response Models. - Increased likelihood of merge conflicts because modifications are made in a single file (e.g. developers adding a model / endpoint at the end of the file).
- If you generate the Controller or just the Controller’s Interface, you will find it hard to deviate from the standard Controllers design e.g. Vertical Slice Architecture using ApiEndpoints.
- Similar for Model Generation, it’s harder to add features such as defensive copying for objects in the constructor (e.g.
List
) or adding custom convenience constructors. It’s hard / impossible to annotate custom JSON Converters or custom Validation on the Model as well.