[REQ] Add CRUD transformation to the OpenAPI schema before codegen
CRUD is mostly boilerplate code so its code can be generated in order to avoid writing it from scratch.
This could be done by adding operations for CRUD for the models the user specifies(tags might be more suitable for this as definitions also include Response Classes). For example in the Pet Store Specification instead of specifying the operations addPet,updatePet the user could somehow say for Pet generate Create,Update and provide some sensible defaults and options to control various aspects of the CRUD. This will also help to guide towards best practices for CRUD with no extra effort.
The transformations of the OpenAPI Schema could be useful in other ways too in the future to add features to the codegen that are language-independent and act upon the specification and not the implementations.
Describe the solution you'd like
Instead of describing the paths in detail the user could input in the [definitions] section a crud: property where they could then specify for each of the operations the options they want like:
definitions:
Order:
title: Pet Order
description: An order for a pets from the pet store
type: object
crud:
create: basic
read: basic
update:
auth:
delete:
auth:
properties:
id:
type: integer
format: int64
petId:
type: integer
format: int64
quantity:
type: integer
format: int32
shipDate:
type: string
format: date-time
status:
type: string
description: Order Status
enum:
- placed
- approved
- delivered
complete:
type: boolean
default: false
xml:
name: Order
Additional context
The OAS is a model for common Http API systems. This means it can be manipulated using Model Driven Development (an academic discipline that revolves around a central evolving model relying on code generation to get a functioning software), more specifically model transformations. By adding such support to the codegen process many more features could be implemented to provide more complete API stubs.