Skip to content

Commit 02d6cd5

Browse files
authored
Merge pull request #3368 from mpacer/api_improvements
API spec improvements, API handler improvements
2 parents 74e2429 + 5fd7d52 commit 02d6cd5

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

notebook/services/api/api.yaml

+33-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ info:
77
name: Jupyter Project
88
url: https://jupyter.org
99
# will be prefixed to all paths
10-
basePath: /api
10+
basePath: /
1111
produces:
1212
- application/json
1313
consumes:
@@ -53,7 +53,9 @@ parameters:
5353
type: string
5454

5555
paths:
56-
/contents/{path}:
56+
57+
58+
/api/contents/{path}:
5759
parameters:
5860
- $ref: '#/parameters/path'
5961
get:
@@ -252,7 +254,7 @@ paths:
252254
description: URL for the removed file
253255
type: string
254256
format: url
255-
/contents/{path}/checkpoints:
257+
/api/contents/{path}/checkpoints:
256258
parameters:
257259
- $ref: '#/parameters/path'
258260
get:
@@ -310,7 +312,7 @@ paths:
310312
reason:
311313
type: string
312314
description: Explanation of error reason
313-
/contents/{path}/checkpoints/{checkpoint_id}:
315+
/api/contents/{path}/checkpoints/{checkpoint_id}:
314316
post:
315317
summary: Restore a file to a particular checkpointed state
316318
parameters:
@@ -342,7 +344,7 @@ paths:
342344
responses:
343345
204:
344346
description: Checkpoint deleted
345-
/sessions/{session}:
347+
/api/sessions/{session}:
346348
parameters:
347349
- $ref: '#/parameters/session'
348350
get:
@@ -380,7 +382,7 @@ paths:
380382
description: Session (and kernel) were deleted
381383
410:
382384
description: "Kernel was deleted before the session, and the session was *not* deleted (TODO - check to make sure session wasn't deleted)"
383-
/sessions:
385+
/api/sessions:
384386
get:
385387
summary: List available sessions
386388
tags:
@@ -422,7 +424,7 @@ paths:
422424
short_message:
423425
type: string
424426

425-
/kernels:
427+
/api/kernels:
426428
get:
427429
summary: List the JSON data for all kernels that are currently running
428430
tags:
@@ -457,7 +459,7 @@ paths:
457459
description: Model for started kernel
458460
type: string
459461
format: url
460-
/kernels/{kernel_id}:
462+
/api/kernels/{kernel_id}:
461463
parameters:
462464
- $ref: '#/parameters/kernel'
463465
get:
@@ -476,7 +478,7 @@ paths:
476478
responses:
477479
204:
478480
description: Kernel deleted
479-
/kernels/{kernel_id}/interrupt:
481+
/api/kernels/{kernel_id}/interrupt:
480482
parameters:
481483
- $ref: '#/parameters/kernel'
482484
post:
@@ -486,7 +488,7 @@ paths:
486488
responses:
487489
204:
488490
description: Kernel interrupted
489-
/kernels/{kernel_id}/restart:
491+
/api/kernels/{kernel_id}/restart:
490492
parameters:
491493
- $ref: '#/parameters/kernel'
492494
post:
@@ -504,7 +506,7 @@ paths:
504506
schema:
505507
$ref: '#/definitions/Kernel'
506508

507-
/kernelspecs:
509+
/api/kernelspecs:
508510
get:
509511
summary: Get kernel specs
510512
tags:
@@ -522,7 +524,7 @@ paths:
522524
type: object
523525
additionalProperties:
524526
$ref: '#/definitions/KernelSpec'
525-
/config/{section_name}:
527+
/api/config/{section_name}:
526528
get:
527529
summary: Get a configuration section by name
528530
parameters:
@@ -550,7 +552,7 @@ paths:
550552
schema:
551553
type: object
552554

553-
/terminals:
555+
/api/terminals:
554556
get:
555557
summary: Get available terminals
556558
tags:
@@ -581,7 +583,7 @@ paths:
581583
404:
582584
description: Not found
583585

584-
/terminals/{terminal_id}:
586+
/api/terminals/{terminal_id}:
585587
get:
586588
summary: Get a terminal session corresponding to an id.
587589
tags:
@@ -615,14 +617,29 @@ paths:
615617

616618

617619

618-
/status:
620+
/api/status:
619621
get:
620-
summary: Get the current status / activity of the server
622+
summary: Get the current status/activity of the server.
623+
tags:
624+
- status
621625
responses:
622626
200:
623627
description: The current status of the server
624628
schema:
625629
$ref: '#/definitions/APIStatus'
630+
631+
/api/spec.yaml:
632+
get:
633+
summary: Get the current spec for the notebook server's APIs.
634+
tags:
635+
- api-spec
636+
produces:
637+
- text/x-yaml
638+
responses:
639+
200:
640+
description: The current spec for the notebook server's APIs.
641+
schema:
642+
type: file
626643
definitions:
627644
APIStatus:
628645
description: |

notebook/services/api/handlers.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ def initialize(self):
2121
@web.authenticated
2222
def get(self):
2323
self.log.warning("Serving api spec (experimental, incomplete)")
24-
self.set_header('Content-Type', 'text/x-yaml')
2524
return web.StaticFileHandler.get(self, 'api.yaml')
25+
26+
def get_content_type(self):
27+
return 'text/x-yaml'
2628

2729
class APIStatusHandler(APIHandler):
2830

0 commit comments

Comments
 (0)