@inklok/api-spec 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -0
- package/components/responses.yaml +36 -0
- package/components/schemas.yaml +55 -0
- package/components/security.yaml +9 -0
- package/openapi.yaml +5750 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# OpenAPI Specification — OpaqueInk Core API
|
|
2
|
+
|
|
3
|
+
This directory contains the **canonical OpenAPI v3 specification** for OpaqueInk core Lambda endpoints.
|
|
4
|
+
|
|
5
|
+
## Ownership
|
|
6
|
+
|
|
7
|
+
**This specification is owned by `opaqueink_infra` and is the single source of truth for API contracts.**
|
|
8
|
+
|
|
9
|
+
- API Gateway routes are generated from this specification
|
|
10
|
+
- Terraform uses this spec to configure API Gateway integrations
|
|
11
|
+
- `opaqueink_core` consumes this spec but does not own it
|
|
12
|
+
- All API changes must be made here first, then propagated to implementations
|
|
13
|
+
|
|
14
|
+
## API URL Configuration
|
|
15
|
+
|
|
16
|
+
**⚠️ IMPORTANT: The API server URL is configured in `openapi.yaml` under the `servers` section.**
|
|
17
|
+
|
|
18
|
+
To update the API Gateway URL, edit the `servers` section in `openapi.yaml`:
|
|
19
|
+
|
|
20
|
+
```yaml
|
|
21
|
+
servers:
|
|
22
|
+
- url: https://YOUR-API-GATEWAY-URL/prod
|
|
23
|
+
description: Production API Gateway
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The Scalar documentation build script automatically reads this URL from the OpenAPI spec, so updating it here will update the documentation as well.
|
|
27
|
+
|
|
28
|
+
**Current API URL:** `https://4rh4k08rih.execute-api.us-east-2.amazonaws.com/prod`
|
|
29
|
+
|
|
30
|
+
## Structure
|
|
31
|
+
|
|
32
|
+
- **`openapi.yaml`** - Complete OpenAPI v3 specification with inline component references
|
|
33
|
+
- **`components/`** - Modular component definitions (for maintainability, but consolidated into openapi.yaml for API Gateway)
|
|
34
|
+
- `schemas.yaml` - Data model schemas
|
|
35
|
+
- `responses.yaml` - Standard response definitions
|
|
36
|
+
- `security.yaml` - Security scheme definitions
|
|
37
|
+
- **`package.json`** - Node.js dependencies for validation and deployment
|
|
38
|
+
|
|
39
|
+
## Building and Validation
|
|
40
|
+
|
|
41
|
+
### Install Dependencies
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cd api
|
|
45
|
+
npm install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Validate the Specification
|
|
49
|
+
|
|
50
|
+
**Using basic validation:**
|
|
51
|
+
```bash
|
|
52
|
+
npm install
|
|
53
|
+
npm run validate-basic
|
|
54
|
+
# or directly:
|
|
55
|
+
node validate-basic.js
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Using the validation script** (includes multiple fallbacks):
|
|
59
|
+
```bash
|
|
60
|
+
chmod +x validate.sh
|
|
61
|
+
./validate.sh
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Build Documentation
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm run build-docs
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This builds the Scalar API documentation with interactive "Try-It-Out" functionality.
|
|
71
|
+
|
|
72
|
+
### Deploy Documentation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
export S3_BUCKET_NAME="your-bucket-name"
|
|
76
|
+
export CLOUDFRONT_DISTRIBUTION_ID="your-distribution-id"
|
|
77
|
+
npm run deploy-docs
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This builds and deploys the documentation to S3/CloudFront.
|
|
81
|
+
|
|
82
|
+
## Integration with API Gateway
|
|
83
|
+
|
|
84
|
+
The `openapi.yaml` file uses `x-amazon-apigateway-*` extensions to define:
|
|
85
|
+
|
|
86
|
+
- Lambda integrations (`x-amazon-apigateway-integration`)
|
|
87
|
+
- Authentication configuration
|
|
88
|
+
- Request/response mappings
|
|
89
|
+
- CORS behavior
|
|
90
|
+
|
|
91
|
+
Terraform in `../api_gateway/` imports this specification to configure API Gateway.
|
|
92
|
+
|
|
93
|
+
## API Versioning
|
|
94
|
+
|
|
95
|
+
**⚠️ HARD REQUIREMENT: All new endpoints MUST be versioned using `/v1/` path prefix.**
|
|
96
|
+
|
|
97
|
+
See [API_VERSIONING.md](API_VERSIONING.md) for the complete versioning strategy and requirements.
|
|
98
|
+
|
|
99
|
+
**Quick Reference:**
|
|
100
|
+
- ✅ New endpoint: `/v1/orgs/{orgId}/members`
|
|
101
|
+
- ❌ Missing version: `/orgs/{orgId}/members` (not allowed for new endpoints)
|
|
102
|
+
|
|
103
|
+
## Adding New Endpoints
|
|
104
|
+
|
|
105
|
+
1. **⚠️ Ensure path includes `/v1/` prefix** (see [API_VERSIONING.md](API_VERSIONING.md))
|
|
106
|
+
2. **Add the path definition** to `openapi.yaml` under `paths:`
|
|
107
|
+
3. **Add the Lambda integration** using `x-amazon-apigateway-integration` extension
|
|
108
|
+
4. **Add schemas** to `components/schemas` if needed
|
|
109
|
+
5. **Add responses** using component references (e.g., `$ref: '#/components/responses/Unauthorized'`)
|
|
110
|
+
6. **Run validation**: `npm run validate-basic`
|
|
111
|
+
7. **Update Terraform** in `../api_gateway/` to reference the new Lambda function
|
|
112
|
+
|
|
113
|
+
## Editing Guidelines
|
|
114
|
+
|
|
115
|
+
- **⚠️ Versioning**: All new endpoints MUST use `/v1/` path prefix (see [API_VERSIONING.md](API_VERSIONING.md))
|
|
116
|
+
- **Operation IDs** must be unique and descriptive (use kebab-case)
|
|
117
|
+
- **All endpoints** require Bearer JWT authentication (defined globally)
|
|
118
|
+
- **Error responses** should use component references from `components/responses`
|
|
119
|
+
- **Schemas** should be defined in `components/schemas` and referenced
|
|
120
|
+
- **Tags** should be used consistently to group related operations
|
|
121
|
+
|
|
122
|
+
## Publishing to npm
|
|
123
|
+
|
|
124
|
+
This package is published to the public npm registry as `@inklok/api-spec` so `opaqueink_core` and other repos can consume it for codegen and type generation.
|
|
125
|
+
|
|
126
|
+
- **Manual publish:** See [PUBLISH.md](PUBLISH.md) for setup and `npm publish` instructions
|
|
127
|
+
- **CI publish:** Create a GitHub Release to trigger `.github/workflows/publish-api-spec.yml`
|
|
128
|
+
- **Consuming:** `npm install @inklok/api-spec`
|
|
129
|
+
|
|
130
|
+
## Reference
|
|
131
|
+
|
|
132
|
+
- [OpenAPI 3.0 Specification](https://swagger.io/specification/)
|
|
133
|
+
- [API Gateway OpenAPI Extensions](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html)
|
|
134
|
+
- [Scalar API Reference](https://github.com/scalar/scalar)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
components:
|
|
2
|
+
responses:
|
|
3
|
+
BadRequest:
|
|
4
|
+
description: Bad request
|
|
5
|
+
content:
|
|
6
|
+
application/json:
|
|
7
|
+
schema:
|
|
8
|
+
$ref: '#/components/schemas/Error'
|
|
9
|
+
|
|
10
|
+
Unauthorized:
|
|
11
|
+
description: Unauthorized - Missing or invalid Bearer token
|
|
12
|
+
content:
|
|
13
|
+
application/json:
|
|
14
|
+
schema:
|
|
15
|
+
$ref: '#/components/schemas/Error'
|
|
16
|
+
|
|
17
|
+
Forbidden:
|
|
18
|
+
description: Forbidden - Insufficient role permissions
|
|
19
|
+
content:
|
|
20
|
+
application/json:
|
|
21
|
+
schema:
|
|
22
|
+
$ref: '#/components/schemas/Error'
|
|
23
|
+
|
|
24
|
+
NotFound:
|
|
25
|
+
description: Resource not found
|
|
26
|
+
content:
|
|
27
|
+
application/json:
|
|
28
|
+
schema:
|
|
29
|
+
$ref: '#/components/schemas/Error'
|
|
30
|
+
|
|
31
|
+
InternalServerError:
|
|
32
|
+
description: Internal server error
|
|
33
|
+
content:
|
|
34
|
+
application/json:
|
|
35
|
+
schema:
|
|
36
|
+
$ref: '#/components/schemas/Error'
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
components:
|
|
2
|
+
schemas:
|
|
3
|
+
Error:
|
|
4
|
+
type: object
|
|
5
|
+
description: Error response
|
|
6
|
+
properties:
|
|
7
|
+
error:
|
|
8
|
+
type: string
|
|
9
|
+
description: Error message
|
|
10
|
+
message:
|
|
11
|
+
type: string
|
|
12
|
+
nullable: true
|
|
13
|
+
description: Additional error details
|
|
14
|
+
|
|
15
|
+
OrkMetadata:
|
|
16
|
+
type: object
|
|
17
|
+
description: Organization Root Key metadata
|
|
18
|
+
properties:
|
|
19
|
+
PK:
|
|
20
|
+
type: string
|
|
21
|
+
description: Partition key (ORG#{orgId})
|
|
22
|
+
SK:
|
|
23
|
+
type: string
|
|
24
|
+
description: Sort key (ORK#{orkId})
|
|
25
|
+
orkId:
|
|
26
|
+
type: string
|
|
27
|
+
description: Unique ORK identifier
|
|
28
|
+
alias:
|
|
29
|
+
type: string
|
|
30
|
+
description: KMS alias for the key
|
|
31
|
+
status:
|
|
32
|
+
type: string
|
|
33
|
+
enum:
|
|
34
|
+
- ACTIVE
|
|
35
|
+
- INACTIVE
|
|
36
|
+
description: ORK status
|
|
37
|
+
createdAt:
|
|
38
|
+
type: string
|
|
39
|
+
format: date-time
|
|
40
|
+
description: Creation timestamp
|
|
41
|
+
lastRotatedAt:
|
|
42
|
+
type: string
|
|
43
|
+
format: date-time
|
|
44
|
+
nullable: true
|
|
45
|
+
description: Last rotation timestamp
|
|
46
|
+
staleWrappedKeyCount:
|
|
47
|
+
type: integer
|
|
48
|
+
description: Count of keys wrapped by this ORK that are now stale
|
|
49
|
+
kmsKeyArn:
|
|
50
|
+
type: string
|
|
51
|
+
description: KMS key ARN
|
|
52
|
+
rotatedFrom:
|
|
53
|
+
type: string
|
|
54
|
+
nullable: true
|
|
55
|
+
description: Previous ORK identifier (if rotated)
|