Skip to content

Commit 58946b2

Browse files
committed
fix: swagger documentation update
- **build.py**: Added missing `file` parameter, fixed response schemas, added enum for kind, better examples - **api.py**: Fixed securityDefinitions syntax, improved config endpoint documentation - **auth.py**: Fixed incorrect summary, removed duplicate definitions, fixed path parameter syntax (from `schema: {type: string}` to `type: string`), added 400 responses
1 parent 426e9a6 commit 58946b2

3 files changed

Lines changed: 101 additions & 93 deletions

File tree

openserverless/rest/api.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ def info():
2424
"""
2525
Info Endpoint
2626
---
27-
securityDefinitions:
28-
openwhiskBasicAuth:
27+
securityDefinitions:
28+
openwhiskBasicAuth:
29+
type: basic
30+
description: OpenWhisk basic authentication using UUID:KEY format
2931
definitions:
3032
Message:
3133
type: object
@@ -93,15 +95,18 @@ def info():
9395
@app.route('/system/config')
9496
def config():
9597
"""
96-
Info Endpoint
98+
Config Endpoint
9799
---
98100
tags:
99101
- Config
102+
summary: Get API configuration data
103+
description: Returns basic configuration data used by this API
104+
operationId: getConfig
100105
responses:
101106
200:
102-
description: Config Endpoint Returns Basic Configuration Data used by this API.
107+
description: Configuration data retrieved successfully
103108
schema:
104-
$ref: '#/definitions/Message'
109+
$ref: '#/definitions/MessageData'
105110
"""
106111
config = {
107112

openserverless/rest/auth.py

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,63 +28,42 @@
2828
@ow_authorize(pass_user_data=True)
2929
def password(login, **kwargs):
3030
"""
31-
Update the user password patching the corresponding wsku/<login> entry.
31+
Update User Password
3232
---
33-
tags:
33+
tags:
3434
- Authentication Api
35-
summary: Login an OpenServerless user using login/password payload
36-
operationId: patchOpsUser
35+
summary: Update user password
36+
description: Update the user password by patching the corresponding WhiskUser entry
37+
operationId: updateUserPassword
3738
security:
3839
- openwhiskBasicAuth: []
3940
consumes:
4041
- application/json
41-
definitions:
42-
LoginUpdateData:
43-
type: object
44-
properties:
45-
password:
46-
type: string
47-
new_password:
48-
type: string
49-
required:
50-
- password
51-
- new_password
52-
MessageData:
53-
type: object
54-
properties:
55-
message:
56-
type: object
57-
status:
58-
type: string
59-
Message:
60-
type: object
61-
properties:
62-
message:
63-
type: string
64-
status:
65-
type: string
6642
parameters:
6743
- in: path
6844
name: login
69-
description: The username requiring the password update.
45+
description: The username requiring the password update
7046
required: true
71-
schema:
72-
type: string
47+
type: string
7348
- in: body
74-
name: User
75-
description: the password update payload.
49+
name: PasswordUpdate
50+
description: Password update payload containing current and new password
7651
required: true
7752
schema:
78-
$ref: '#/definitions/LoginUpdateData'
53+
$ref: '#/definitions/LoginUpdateData'
7954
responses:
8055
200:
81-
description: Logged in User data
56+
description: Password updated successfully
8257
schema:
8358
$ref: '#/definitions/MessageData'
59+
400:
60+
description: Bad request. Missing required fields.
61+
schema:
62+
$ref: '#/definitions/Message'
8463
401:
85-
description: Access denied due to wrong credentials.
64+
description: Unauthorized. Invalid credentials or authorization token.
8665
schema:
87-
$ref: '#/definitions/Message'
66+
$ref: '#/definitions/Message'
8867
"""
8968
update_data = request.get_json()
9069

@@ -99,30 +78,35 @@ def password(login, **kwargs):
9978
@app.route('/system/api/v1/auth',methods=['POST'])
10079
def login():
10180
"""
102-
Perform the user Authentication relying on wsku metadata stored into internal CouchDB.
81+
User Authentication
10382
---
104-
tags:
83+
tags:
10584
- Authentication Api
106-
summary: Login an OpenServerless user using login/password payload
107-
operationId: loginOpsUser
85+
summary: Authenticate user with login credentials
86+
description: Perform user authentication using credentials stored in CouchDB metadata
87+
operationId: authenticateUser
10888
consumes:
10989
- application/json
11090
parameters:
11191
- in: body
112-
name: User
113-
description: The user to login.
92+
name: LoginCredentials
93+
description: User login credentials
11494
required: true
11595
schema:
116-
$ref: '#/definitions/LoginData'
96+
$ref: '#/definitions/LoginData'
11797
responses:
11898
200:
119-
description: Logged in User data
99+
description: Authentication successful. Returns user data including environment variables and quota.
120100
schema:
121101
$ref: '#/definitions/MessageData'
102+
400:
103+
description: Bad request. Missing login or password.
104+
schema:
105+
$ref: '#/definitions/Message'
122106
401:
123-
description: Access denied due to wrong credentials.
107+
description: Unauthorized. Invalid credentials.
124108
schema:
125-
$ref: '#/definitions/Message'
109+
$ref: '#/definitions/Message'
126110
"""
127111
login_data = request.get_json()
128112
auth_service = AuthService()

openserverless/rest/build.py

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,48 @@ def build():
6262
required: true
6363
schema:
6464
type: object
65+
required:
66+
- source
67+
- target
68+
- kind
6569
properties:
6670
source:
6771
type: string
68-
description: Source for the build
72+
description: Source image for the build (e.g., ghcr.io/nuvolaris/openserverless-runtime-python:3.12)
73+
example: "ghcr.io/nuvolaris/openserverless-runtime-python:3.12"
6974
target:
7075
type: string
71-
description: Target for the build
76+
description: Target image name in format username:tag (must match authenticated user)
77+
example: "myuser:custom-tag"
7278
kind:
7379
type: string
74-
description: Kind of the build
80+
description: Runtime kind (python, nodejs, java, php, go, ruby, dotnet)
81+
enum: [python, nodejs, java, php, go, ruby, dotnet]
82+
example: "python"
83+
file:
84+
type: string
85+
description: Base64-encoded requirements file (optional, e.g., requirements.txt for Python)
86+
example: "cmVxdWVzdHM9PTIuMzEuMA=="
7587
responses:
7688
200:
7789
description: Build process initiated successfully.
7890
schema:
79-
$ref: '#/definitions/Message'
91+
type: object
92+
properties:
93+
message:
94+
type: string
95+
example: "Build process initiated successfully. Job: build-myuser-abc123"
96+
data:
97+
type: object
98+
properties:
99+
id:
100+
type: string
101+
description: Unique build ID
102+
example: "550e8400-e29b-41d4-a716-446655440000"
103+
job_name:
104+
type: string
105+
description: Kubernetes job name
106+
example: "build-myuser-abc123"
80107
400:
81108
description: Bad Request. Missing or invalid parameters.
82109
schema:
@@ -168,46 +195,38 @@ def clean():
168195
default: 24
169196
170197
responses:
171-
'200':
198+
200:
172199
description: Successfully cleaned up old build jobs.
173-
content:
174-
application/json:
175-
schema:
176-
type: object
177-
properties:
178-
message:
179-
type: string
180-
example: Cleaned up 5 jobs successfully.
181-
'400':
200+
schema:
201+
type: object
202+
properties:
203+
message:
204+
type: string
205+
example: "Cleaned up 5 jobs successfully."
206+
400:
182207
description: Bad request. No JSON payload provided for cleanup.
183-
content:
184-
application/json:
185-
schema:
186-
type: object
187-
properties:
188-
error:
189-
type: string
190-
example: No JSON payload provided for cleanup.
191-
'401':
208+
schema:
209+
type: object
210+
properties:
211+
error:
212+
type: string
213+
example: "No JSON payload provided for cleanup."
214+
401:
192215
description: Unauthorized. User environment not found.
193-
content:
194-
application/json:
195-
schema:
196-
type: object
197-
properties:
198-
error:
199-
type: string
200-
example: User environment not found
201-
'500':
216+
schema:
217+
type: object
218+
properties:
219+
error:
220+
type: string
221+
example: "User environment not found"
222+
500:
202223
description: Internal server error. Failed to clean up old build jobs.
203-
content:
204-
application/json:
205-
schema:
206-
type: object
207-
properties:
208-
error:
209-
type: string
210-
example: Failed to clean up old build jobs.
224+
schema:
225+
type: object
226+
properties:
227+
error:
228+
type: string
229+
example: "Failed to clean up old build jobs."
211230
"""
212231

213232
auth_result = authorize()

0 commit comments

Comments
 (0)