Loading...
Loading...
Generate OpenAPI specification from ALPS profile. Converts ALPS semantic descriptors to RESTful API definitions with automatic validation.
npx skill4agent add alps-asd/app-state-diagram alps2openapi| ALPS type | HTTP Method | Description |
|---|---|---|
| safe | GET | Read operations |
| unsafe | POST | Create operations (non-idempotent) |
| idempotent | PUT/DELETE/PATCH | Update/Delete operations (idempotent) |
updateeditmodifychangesetreplacedoUpdateUserdoEditPostdoSetStatusdeleteremovecancelcleardestroydoDeleteUserdoRemoveItemdoCancelOrdertogglepatchincrementdecrementdoToggleCompletedoPatchProfilegoTodoListoperationId: goTodoListdoCreateTodooperationId: doCreateTodo| Transition Pattern | Path | Method |
|---|---|---|
| goXxxList | /xxxs | GET |
| goXxxDetail | /xxxs/{xxxId} | GET |
| doCreateXxx | /xxxs | POST |
| doUpdateXxx | /xxxs/{xxxId} | PUT |
| doDeleteXxx | /xxxs/{xxxId} | DELETE |
| doToggleYyy | /xxxs/{xxxId}/yyy | PATCH |
/todos/users/products/order-items/user-profiles/users/{userId}/posts# ALPS
{"id": "todoId", "title": "Task ID", "def": "https://schema.org/identifier"}
# OpenAPI
todoId:
type: string
description: Task IDTodoListTodoListItemTodoDetailTodoDetail| schema.org | OpenAPI |
|---|---|
| https://schema.org/DateTime | |
| https://schema.org/Date | |
| https://schema.org/Time | |
| https://schema.org/Email | |
| https://schema.org/URL | |
| https://schema.org/identifier | |
| https://schema.org/Integer | |
| https://schema.org/Number | |
| https://schema.org/Boolean | |
| https://schema.org/Text | |
{"id": "doCreateTodo", "type": "unsafe", "rt": "#TodoDetail", "descriptor": [
{"href": "#title"},
{"href": "#description"},
{"href": "#dueDate"}
]}requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTodoRequest'CreateTodoRequest:
type: object
properties:
title:
type: string
description:
type: string
dueDate:
type: string
format: date-time
required:
- title| Operation | Success | Client Error | Not Found |
|---|---|---|---|
| GET (single) | 200 | 400 | 404 |
| GET (list) | 200 | 400 | - |
| POST | 201 | 400, 409 | - |
| PUT | 200 | 400 | 404 |
| PATCH | 200 | 400 | 404 |
| DELETE | 204 | 400 | 404 |
components:
schemas:
Error:
type: object
properties:
code:
type: string
description: Error code
message:
type: string
description: Error message
required:
- code
- message
responses:
NotFound:
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
BadRequest:
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'(optional)tag{"id": "goTodoList", "type": "safe", "rt": "#TodoList", "tag": "todo"}tags:
- todonpx @stoplight/spectral-cli lint <output_file>$schematitleopenapi: 3.1.0
info:
title: {alps.title}
description: {alps.doc}
version: 1.0.0
servers:
- url: http://localhost:8080/api
description: Development server
paths:
# Generated from transitions
components:
schemas:
# Generated from semantic descriptors and states
Error:
type: object
properties:
code:
type: string
message:
type: string
required:
- code
- message
responses:
NotFound:
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
BadRequest:
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'npx @stoplight/spectral-cli lint openapi.yaml{
"alps": {
"title": "Todo API",
"descriptor": [
{"id": "todoId", "title": "Task ID"},
{"id": "title", "title": "Title"},
{"id": "completed", "title": "Completed"},
{"id": "TodoList", "descriptor": [
{"href": "#todoId"},
{"href": "#title"},
{"href": "#goTodoDetail"},
{"href": "#doCreateTodo"}
]},
{"id": "goTodoList", "type": "safe", "rt": "#TodoList"},
{"id": "goTodoDetail", "type": "safe", "rt": "#TodoDetail", "descriptor": [
{"href": "#todoId"}
]},
{"id": "doCreateTodo", "type": "unsafe", "rt": "#TodoDetail", "descriptor": [
{"href": "#title"}
]},
{"id": "doDeleteTodo", "type": "idempotent", "rt": "#TodoList", "descriptor": [
{"href": "#todoId"}
]}
]
}
}openapi: 3.1.0
info:
title: Todo API
version: 1.0.0
paths:
/todos:
get:
operationId: goTodoList
summary: Get todo list
responses:
'200':
description: Todo list
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/TodoListItem'
post:
operationId: doCreateTodo
summary: Create todo
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTodoRequest'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/TodoDetail'
'400':
$ref: '#/components/responses/BadRequest'
/todos/{todoId}:
parameters:
- name: todoId
in: path
required: true
schema:
type: string
get:
operationId: goTodoDetail
summary: Get todo detail
responses:
'200':
description: Todo detail
content:
application/json:
schema:
$ref: '#/components/schemas/TodoDetail'
'404':
$ref: '#/components/responses/NotFound'
delete:
operationId: doDeleteTodo
summary: Delete todo
responses:
'204':
description: Deleted
'404':
$ref: '#/components/responses/NotFound'
components:
schemas:
TodoListItem:
type: object
properties:
todoId:
type: string
description: Task ID
title:
type: string
description: Title
required:
- todoId
- title
TodoDetail:
type: object
properties:
todoId:
type: string
title:
type: string
completed:
type: boolean
required:
- todoId
- title
- completed
CreateTodoRequest:
type: object
properties:
title:
type: string
required:
- title
Error:
type: object
properties:
code:
type: string
message:
type: string
required:
- code
- message
responses:
NotFound:
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
BadRequest:
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'