-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi-jsonapi-articles.yaml
More file actions
106 lines (100 loc) · 3.26 KB
/
openapi-jsonapi-articles.yaml
File metadata and controls
106 lines (100 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# OpenAPI Response Validation — JSON:API Example
#
# This configuration demonstrates how the workflow engine validates API
# responses against an OpenAPI specification, including complex response
# formats like JSON:API (https://jsonapi.org/).
#
# Key features:
# - Request validation: incoming requests are checked against the spec
# - Response validation: outgoing responses are checked against the spec
# - response_action: "warn" logs violations, "error" rejects them with 500
#
# The JSON:API spec (specs/jsonapi-articles.yaml) defines a complex nested
# response envelope with required fields (data, type, id, attributes) that
# the engine validates automatically.
requires:
plugins:
- name: workflow-plugin-http
- name: workflow-plugin-openapi
modules:
# HTTP server
- name: jsonapi-server
type: http.server
config:
address: ":8096"
# HTTP router
- name: jsonapi-router
type: http.router
dependsOn:
- jsonapi-server
# OpenAPI module with response validation enabled
- name: articles-api
type: openapi
dependsOn:
- jsonapi-router
config:
spec_file: specs/jsonapi-articles.yaml
base_path: /api/v1
router: jsonapi-router
validation:
request: true
response: true
response_action: warn # "warn" = log and pass through; "error" = reject with 500
swagger_ui:
enabled: true
path: /docs
# Pipelines that generate JSON:API compliant responses.
# The OpenAPI response validation ensures these conform to the spec.
pipelines:
list-articles:
steps:
- name: build-response
type: step.set
config:
values:
response_status: 200
response_headers:
Content-Type: "application/vnd.api+json"
response_body: |
{
"data": [
{
"type": "articles",
"id": "1",
"attributes": {
"title": "Getting Started with Workflow Engine",
"body": "This article explains how to use the workflow engine...",
"created_at": "2024-01-15T10:30:00Z"
},
"relationships": {
"author": {
"data": {"type": "people", "id": "42"}
}
}
}
],
"meta": {"total": 1, "page": 1, "per_page": 10},
"links": {"self": "/api/v1/articles"}
}
get-article:
steps:
- name: build-response
type: step.set
config:
values:
response_status: 200
response_headers:
Content-Type: "application/vnd.api+json"
response_body: |
{
"data": {
"type": "articles",
"id": "1",
"attributes": {
"title": "Getting Started with Workflow Engine",
"body": "This article explains how to use the workflow engine...",
"created_at": "2024-01-15T10:30:00Z"
}
},
"links": {"self": "/api/v1/articles/1"}
}