feat(templates): add OpenAPI-first CRUD app scaffold with mock data
- include CRUD OpenAPI spec - add in-memory mock data store - implement OpenAPI-bound route handlers - provide runnable FastAPI bootstrap - include end-to-end integration test
This commit is contained in:
115
openapi_first/templates/crud_app/openapi.yaml
Normal file
115
openapi_first/templates/crud_app/openapi.yaml
Normal file
@@ -0,0 +1,115 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: CRUD Example Service
|
||||
version: "1.0.0"
|
||||
description: Minimal OpenAPI-first CRUD service with in-memory mock data.
|
||||
|
||||
paths:
|
||||
/items:
|
||||
get:
|
||||
operationId: list_items
|
||||
summary: List all items
|
||||
responses:
|
||||
"200":
|
||||
description: List of items
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Item"
|
||||
|
||||
post:
|
||||
operationId: create_item
|
||||
summary: Create a new item
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ItemCreate"
|
||||
responses:
|
||||
"201":
|
||||
description: Item created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Item"
|
||||
|
||||
/items/{item_id}:
|
||||
get:
|
||||
operationId: get_item
|
||||
summary: Get item by ID
|
||||
parameters:
|
||||
- name: item_id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
responses:
|
||||
"200":
|
||||
description: Item found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Item"
|
||||
|
||||
put:
|
||||
operationId: update_item
|
||||
summary: Update an item
|
||||
parameters:
|
||||
- name: item_id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ItemCreate"
|
||||
responses:
|
||||
"200":
|
||||
description: Item updated
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Item"
|
||||
|
||||
delete:
|
||||
operationId: delete_item
|
||||
summary: Delete an item
|
||||
parameters:
|
||||
- name: item_id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
responses:
|
||||
"204":
|
||||
description: Item deleted
|
||||
|
||||
components:
|
||||
schemas:
|
||||
Item:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
price:
|
||||
type: number
|
||||
format: float
|
||||
required: [id, name, price]
|
||||
|
||||
ItemCreate:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
price:
|
||||
type: number
|
||||
format: float
|
||||
required: [name, price]
|
||||
Reference in New Issue
Block a user