Skip to content

Commit cc8d217

Browse files
authored
openapi: trip the prefix from the path, only keep the query (#1777)
Remove the path prefix from the API paths, this way it can be adjusted easily. See: - https://swagger.io/docs/specification/v3_0/api-host-and-base-path/ - https://drf-spectacular.readthedocs.io/en/latest/settings.html
1 parent be3d146 commit cc8d217

File tree

3 files changed

+64
-38
lines changed

3 files changed

+64
-38
lines changed

ansible_ai_connect/main/settings/development.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
"DESCRIPTION": "Equip the automation developer at Lightspeed.",
2727
"VERSION": API_VERSION,
2828
"SERVE_INCLUDE_SCHEMA": False,
29+
"SERVERS": [
30+
{
31+
"url": "https://lightspeed-instance/api/v1",
32+
"description": "Direct access to a Lightspeed instance",
33+
},
34+
{
35+
"url": "https://aap/api/lightspeed/v1",
36+
"description": "Access through an Ansible Automation Platfrom gateway",
37+
},
38+
],
2939
# OTHER SETTINGS
3040
"TAGS": [
3141
{"name": "ai", "description": "AI-related operations"},
@@ -34,6 +44,7 @@
3444
{"name": "wca", "description": "watsonx Code Assistant"},
3545
],
3646
"SCHEMA_PATH_PREFIX": r"/api/v[0-9]+",
47+
"SCHEMA_PATH_PREFIX_TRIM": True,
3748
"PREPROCESSING_HOOKS": ["ansible_ai_connect.ai.api.openapi.preprocessing_filter_spec"],
3849
}
3950

tools/openapi-schema/ansible-ai-connect-service.json

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"description": "Equip the automation developer at Lightspeed."
77
},
88
"paths": {
9-
"/api/v1/ai/chat/": {
9+
"/ai/chat/": {
1010
"post": {
1111
"operationId": "ai_chat_create",
1212
"description": "Send a message to the backend chatbot service and get a reply.",
@@ -77,7 +77,7 @@
7777
}
7878
}
7979
},
80-
"/api/v1/ai/completions/": {
80+
"/ai/completions/": {
8181
"post": {
8282
"operationId": "ai_completions_create",
8383
"description": "Returns inline code suggestions based on a given Ansible editor context.",
@@ -165,7 +165,7 @@
165165
}
166166
}
167167
},
168-
"/api/v1/ai/contentmatches/": {
168+
"/ai/contentmatches/": {
169169
"post": {
170170
"operationId": "ai_contentmatches_create",
171171
"description": "Returns content matches that were the highest likelihood sources for a given code suggestion.",
@@ -230,7 +230,7 @@
230230
}
231231
}
232232
},
233-
"/api/v1/ai/explanations/": {
233+
"/ai/explanations/": {
234234
"post": {
235235
"operationId": "ai_explanations_create",
236236
"description": "Returns a text that explains a playbook.",
@@ -298,7 +298,7 @@
298298
}
299299
}
300300
},
301-
"/api/v1/ai/explanations/role/": {
301+
"/ai/explanations/role/": {
302302
"post": {
303303
"operationId": "ai_explanations_role_create",
304304
"description": "Returns a text that explains a role.",
@@ -366,7 +366,7 @@
366366
}
367367
}
368368
},
369-
"/api/v1/ai/feedback/": {
369+
"/ai/feedback/": {
370370
"post": {
371371
"operationId": "ai_feedback_create",
372372
"description": "Feedback API for the AI service",
@@ -430,7 +430,7 @@
430430
}
431431
}
432432
},
433-
"/api/v1/ai/generations/playbook/": {
433+
"/ai/generations/playbook/": {
434434
"post": {
435435
"operationId": "ai_generations_playbook_create",
436436
"description": "Returns a playbook based on a text input.",
@@ -498,7 +498,7 @@
498498
}
499499
}
500500
},
501-
"/api/v1/ai/generations/role/": {
501+
"/ai/generations/role/": {
502502
"post": {
503503
"operationId": "ai_generations_role_create",
504504
"description": "Returns a role based on a text input.",
@@ -554,7 +554,7 @@
554554
}
555555
}
556556
},
557-
"/api/v1/ai/streaming_chat/": {
557+
"/ai/streaming_chat/": {
558558
"post": {
559559
"operationId": "ai_streaming_chat_create",
560560
"description": "Send a message to the backend chatbot service and get a streaming reply.",
@@ -625,7 +625,7 @@
625625
}
626626
}
627627
},
628-
"/api/v1/health/": {
628+
"/health/": {
629629
"get": {
630630
"operationId": "health_retrieve",
631631
"description": "Service Liveness Probe View",
@@ -646,7 +646,7 @@
646646
}
647647
}
648648
},
649-
"/api/v1/health/status/": {
649+
"/health/status/": {
650650
"get": {
651651
"operationId": "health_status_retrieve",
652652
"description": "Service Health Check",
@@ -702,7 +702,7 @@
702702
}
703703
}
704704
},
705-
"/api/v1/health/status/chatbot/": {
705+
"/health/status/chatbot/": {
706706
"get": {
707707
"operationId": "health_status_chatbot_retrieve",
708708
"description": "Chatbot health check",
@@ -723,7 +723,7 @@
723723
}
724724
}
725725
},
726-
"/api/v1/me/": {
726+
"/me/": {
727727
"get": {
728728
"operationId": "me_retrieve",
729729
"tags": [
@@ -748,7 +748,7 @@
748748
}
749749
}
750750
},
751-
"/api/v1/me/summary/": {
751+
"/me/summary/": {
752752
"get": {
753753
"operationId": "me_summary_retrieve",
754754
"tags": [
@@ -773,7 +773,7 @@
773773
}
774774
}
775775
},
776-
"/api/v1/telemetry/": {
776+
"/telemetry/": {
777777
"get": {
778778
"operationId": "telemetry_settings_get",
779779
"summary": "Get the telemetry settings for an Organisation",
@@ -886,7 +886,7 @@
886886
}
887887
}
888888
},
889-
"/api/v1/wca/apikey/": {
889+
"/wca/apikey/": {
890890
"get": {
891891
"operationId": "wca_api_key_get",
892892
"summary": "Get WCA key for an Organisation",
@@ -1043,7 +1043,7 @@
10431043
}
10441044
}
10451045
},
1046-
"/api/v1/wca/apikey/test/": {
1046+
"/wca/apikey/test/": {
10471047
"get": {
10481048
"operationId": "wca_api_key_validator_get",
10491049
"summary": "Validate WCA key for an Organisation",
@@ -1085,7 +1085,7 @@
10851085
}
10861086
}
10871087
},
1088-
"/api/v1/wca/modelid/": {
1088+
"/wca/modelid/": {
10891089
"get": {
10901090
"operationId": "wca_model_id_get",
10911091
"summary": "Get WCA Model Id for an Organisation",
@@ -1198,7 +1198,7 @@
11981198
}
11991199
}
12001200
},
1201-
"/api/v1/wca/modelid/test/": {
1201+
"/wca/modelid/test/": {
12021202
"get": {
12031203
"operationId": "wca_model_id_validator_get",
12041204
"summary": "Validate WCA Model Id for an Organisation",
@@ -2429,6 +2429,16 @@
24292429
}
24302430
}
24312431
},
2432+
"servers": [
2433+
{
2434+
"url": "https://lightspeed-instance/api/v1",
2435+
"description": "Direct access to a Lightspeed instance"
2436+
},
2437+
{
2438+
"url": "https://aap/api/lightspeed/v1",
2439+
"description": "Access through an Ansible Automation Platfrom gateway"
2440+
}
2441+
],
24322442
"tags": [
24332443
{
24342444
"name": "ai",

tools/openapi-schema/ansible-ai-connect-service.yaml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ info:
44
version: 1.0.0 (v1)
55
description: Equip the automation developer at Lightspeed.
66
paths:
7-
/api/v1/ai/chat/:
7+
/ai/chat/:
88
post:
99
operationId: ai_chat_create
1010
description: Send a message to the backend chatbot service and get a reply.
@@ -47,7 +47,7 @@ paths:
4747
description: Internal server error
4848
'503':
4949
description: Service unavailable
50-
/api/v1/ai/completions/:
50+
/ai/completions/:
5151
post:
5252
operationId: ai_completions_create
5353
description: Returns inline code suggestions based on a given Ansible editor
@@ -111,7 +111,7 @@ paths:
111111
description: Request was throttled
112112
'503':
113113
description: Service Unavailable
114-
/api/v1/ai/contentmatches/:
114+
/ai/contentmatches/:
115115
post:
116116
operationId: ai_contentmatches_create
117117
description: Returns content matches that were the highest likelihood sources
@@ -151,7 +151,7 @@ paths:
151151
description: Request was throttled
152152
'503':
153153
description: Service Unavailable
154-
/api/v1/ai/explanations/:
154+
/ai/explanations/:
155155
post:
156156
operationId: ai_explanations_create
157157
description: Returns a text that explains a playbook.
@@ -192,7 +192,7 @@ paths:
192192
description: Request was throttled
193193
'503':
194194
description: Service Unavailable
195-
/api/v1/ai/explanations/role/:
195+
/ai/explanations/role/:
196196
post:
197197
operationId: ai_explanations_role_create
198198
description: Returns a text that explains a role.
@@ -233,7 +233,7 @@ paths:
233233
description: Request was throttled
234234
'503':
235235
description: Service Unavailable
236-
/api/v1/ai/feedback/:
236+
/ai/feedback/:
237237
post:
238238
operationId: ai_feedback_create
239239
description: Feedback API for the AI service
@@ -275,7 +275,7 @@ paths:
275275
description: Bad Request
276276
'401':
277277
description: Unauthorized
278-
/api/v1/ai/generations/playbook/:
278+
/ai/generations/playbook/:
279279
post:
280280
operationId: ai_generations_playbook_create
281281
description: Returns a playbook based on a text input.
@@ -316,7 +316,7 @@ paths:
316316
description: Request was throttled
317317
'503':
318318
description: Service Unavailable
319-
/api/v1/ai/generations/role/:
319+
/ai/generations/role/:
320320
post:
321321
operationId: ai_generations_role_create
322322
description: Returns a role based on a text input.
@@ -349,7 +349,7 @@ paths:
349349
description: ''
350350
'401':
351351
description: Unauthorized
352-
/api/v1/ai/streaming_chat/:
352+
/ai/streaming_chat/:
353353
post:
354354
operationId: ai_streaming_chat_create
355355
description: Send a message to the backend chatbot service and get a streaming
@@ -393,7 +393,7 @@ paths:
393393
description: Internal server error
394394
'503':
395395
description: Service unavailable
396-
/api/v1/health/:
396+
/health/:
397397
get:
398398
operationId: health_retrieve
399399
description: Service Liveness Probe View
@@ -406,7 +406,7 @@ paths:
406406
responses:
407407
'200':
408408
description: OK
409-
/api/v1/health/status/:
409+
/health/status/:
410410
get:
411411
operationId: health_status_retrieve
412412
description: Service Health Check
@@ -442,7 +442,7 @@ paths:
442442
description: ''
443443
'500':
444444
description: One or more backend services are unavailable.
445-
/api/v1/health/status/chatbot/:
445+
/health/status/chatbot/:
446446
get:
447447
operationId: health_status_chatbot_retrieve
448448
description: Chatbot health check
@@ -455,7 +455,7 @@ paths:
455455
responses:
456456
'200':
457457
description: OK
458-
/api/v1/me/:
458+
/me/:
459459
get:
460460
operationId: me_retrieve
461461
tags:
@@ -469,7 +469,7 @@ paths:
469469
schema:
470470
$ref: '#/components/schemas/UserResponse'
471471
description: ''
472-
/api/v1/me/summary/:
472+
/me/summary/:
473473
get:
474474
operationId: me_summary_retrieve
475475
tags:
@@ -483,7 +483,7 @@ paths:
483483
schema:
484484
$ref: '#/components/schemas/MarkdownUserResponse'
485485
description: ''
486-
/api/v1/telemetry/:
486+
/telemetry/:
487487
get:
488488
operationId: telemetry_settings_get
489489
summary: Get the telemetry settings for an Organisation
@@ -552,7 +552,7 @@ paths:
552552
description: Internal service error
553553
'501':
554554
description: Not implemented
555-
/api/v1/wca/apikey/:
555+
/wca/apikey/:
556556
get:
557557
operationId: wca_api_key_get
558558
summary: Get WCA key for an Organisation
@@ -649,7 +649,7 @@ paths:
649649
description: Internal service error
650650
'501':
651651
description: Not implemented
652-
/api/v1/wca/apikey/test/:
652+
/wca/apikey/test/:
653653
get:
654654
operationId: wca_api_key_validator_get
655655
summary: Validate WCA key for an Organisation
@@ -674,7 +674,7 @@ paths:
674674
description: Internal service error
675675
'501':
676676
description: Not implemented
677-
/api/v1/wca/modelid/:
677+
/wca/modelid/:
678678
get:
679679
operationId: wca_model_id_get
680680
summary: Get WCA Model Id for an Organisation
@@ -743,7 +743,7 @@ paths:
743743
description: Internal service error
744744
'501':
745745
description: Not implemented
746-
/api/v1/wca/modelid/test/:
746+
/wca/modelid/test/:
747747
get:
748748
operationId: wca_model_id_validator_get
749749
summary: Validate WCA Model Id for an Organisation
@@ -1662,6 +1662,11 @@ components:
16621662
oauth2:
16631663
type: oauth2
16641664
flows: {}
1665+
servers:
1666+
- url: https://lightspeed-instance/api/v1
1667+
description: Direct access to a Lightspeed instance
1668+
- url: https://aap/api/lightspeed/v1
1669+
description: Access through an Ansible Automation Platfrom gateway
16651670
tags:
16661671
- name: ai
16671672
description: AI-related operations

0 commit comments

Comments
 (0)