You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/api-clients.md
+27-27Lines changed: 27 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -384,7 +384,7 @@ First, install the API documentation views. These will include the schema resour
384
384
385
385
urlpatterns = [
386
386
...
387
-
url(r'^docs/', include_docs_urls(title='My API service'))
387
+
url(r'^docs/', include_docs_urls(title='My API service'), name='api-docs'),
388
388
]
389
389
390
390
Once the API documentation URLs are installed, you'll be able to include both the required JavaScript resources. Note that the ordering of these two lines is important, as the schema loading requires CoreAPI to already be installed.
@@ -401,14 +401,14 @@ Once the API documentation URLs are installed, you'll be able to include both th
401
401
402
402
The `coreapi` library, and the `schema` object will now both be available on the `window` instance.
403
403
404
-
const coreapi = window.coreapi
405
-
const schema = window.schema
404
+
const coreapi = window.coreapi;
405
+
const schema = window.schema;
406
406
407
407
## Instantiating a client
408
408
409
409
In order to interact with the API you'll need a client instance.
410
410
411
-
var client = new coreapi.Client()
411
+
var client = new coreapi.Client();
412
412
413
413
Typically you'll also want to provide some authentication credentials when
414
414
instantiating the client.
@@ -421,9 +421,9 @@ the user to login, and then instantiate a client using session authentication:
421
421
422
422
let auth = new coreapi.auth.SessionAuthentication({
423
423
csrfCookieName: 'csrftoken',
424
-
csrfHeaderName: 'X-CSRFToken'
425
-
})
426
-
let client = new coreapi.Client({auth: auth})
424
+
csrfHeaderName: 'X-CSRFToken',
425
+
});
426
+
let client = new coreapi.Client({auth: auth});
427
427
428
428
The authentication scheme will handle including a CSRF header in any outgoing
429
429
requests for unsafe HTTP methods.
@@ -434,10 +434,10 @@ The `TokenAuthentication` class can be used to support REST framework's built-in
434
434
`TokenAuthentication`, as well as OAuth and JWT schemes.
435
435
436
436
let auth = new coreapi.auth.TokenAuthentication({
437
-
scheme: 'JWT'
438
-
token: '<token>'
439
-
})
440
-
let client = new coreapi.Client({auth: auth})
437
+
scheme: 'JWT',
438
+
token: '<token>',
439
+
});
440
+
let client = new coreapi.Client({auth: auth});
441
441
442
442
When using TokenAuthentication you'll probably need to implement a login flow
443
443
using the CoreAPI client.
@@ -448,20 +448,20 @@ request to an "obtain token" endpoint
448
448
For example, using the "Django REST framework JWT" package
@@ -512,12 +512,12 @@ The coreapi package is available on NPM.
512
512
513
513
You'll either want to include the API schema in your codebase directly, by copying it from the `schema.js` resource, or else load the schema asynchronously. For example:
0 commit comments