@@ -139,38 +139,51 @@ that credentials are not leaked across differing APIs.
139
139
140
140
The format for adding a new credential is:
141
141
142
- coreapi credentials add <domain> <credentials string>
142
+ $ coreapi credentials add <domain> <credentials string>
143
143
144
144
For instance:
145
145
146
- coreapi credentials add api.example.org "Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"
146
+ $ coreapi credentials add api.example.org "Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"
147
147
148
148
The optional ` --auth ` flag also allows you to add specific types of authentication,
149
149
handling the encoding for you. Currently only ` "basic" ` is supported as an option here.
150
150
For example:
151
151
152
- coreapi credentials add api.example.org tomchristie:foobar --auth basic
152
+ $ coreapi credentials add api.example.org tomchristie:foobar --auth basic
153
153
154
154
You can also add specific request headers, using the ` headers ` command:
155
155
156
- coreapi headers add api.example.org x-api-version 2
156
+ $ coreapi headers add api.example.org x-api-version 2
157
157
158
158
For more information and a listing of the available subcommands use `coreapi
159
159
credentials --help` or ` coreapi headers --help`.
160
160
161
+ ## Codecs
162
+
163
+ By default the command line client only includes support for reading Core JSON
164
+ schemas, however it for installing additional codecs.
165
+
166
+ $ pip install openapi-codec jsonhyperschema-codec hal-codec
167
+ $ coreapi codecs show
168
+ Codecs
169
+ corejson "application/vnd.coreapi+json"
170
+ openapi "application/openapi+json"
171
+ jsonhyperschema "application/schema+json"
172
+ hal "application/hal+json"
173
+
161
174
## Utilities
162
175
163
176
The command line client includes functionality for bookmarking API URLs
164
177
under a memorable name. For example, you can add a bookmark for the
165
178
existing API, like so...
166
179
167
- coreapi bookmarks add accountmanagement
180
+ $ coreapi bookmarks add accountmanagement
168
181
169
182
There is also functionality for navigating forward or backward through the
170
183
history of which API URLs have been accessed.
171
184
172
- coreapi history show
173
- coreapi history back
185
+ $ coreapi history show
186
+ $ coreapi history back
174
187
175
188
For more information and a listing of the available subcommands use
176
189
` coreapi bookmarks --help ` or ` coreapi history --help ` .
@@ -179,20 +192,20 @@ For more information and a listing of the available subcommands use
179
192
180
193
To display the current ` Document ` :
181
194
182
- coreapi show
195
+ $ coreapi show
183
196
184
197
To reload the current ` Document ` from the network:
185
198
186
- coreapi reload
199
+ $ coreapi reload
187
200
188
201
To load a schema file from disk:
189
202
190
- coreapi load my-api-schema.json --format corejson
203
+ $ coreapi load my-api-schema.json --format corejson
191
204
192
205
To remove the current document, along with all currently saved history,
193
206
credentials, headers and bookmarks:
194
207
195
- coreapi clear
208
+ $ coreapi clear
196
209
197
210
---
198
211
@@ -206,7 +219,7 @@ API that exposes a supported schema format.
206
219
You'll need to install the ` coreapi ` package using ` pip ` before you can get
207
220
started.
208
221
209
- pip install coreapi
222
+ $ pip install coreapi
210
223
211
224
In order to start working with an API, we first need a ` Client ` instance. The
212
225
client holds any configuration around which codecs and transports are supported
@@ -263,14 +276,15 @@ and subsequently to receive JSON responses made against the API.
263
276
You can use a codec directly, in order to load an existing schema definition,
264
277
and return the resulting ` Document ` .
265
278
266
- schema_definition = open('my-api-schema.json', 'r').read()
279
+ input_file = open('my-api-schema.json', 'rb')
280
+ schema_definition = input_file.read()
267
281
codec = codecs.CoreJSONCodec()
268
282
schema = codec.load(schema_definition)
269
283
270
284
You can also use a codec directly to generate a schema definition given a ` Document ` instance:
271
285
272
286
schema_definition = codec.dump(schema)
273
- output_file = open('my-api-schema.json', 'r ')
287
+ output_file = open('my-api-schema.json', 'rb ')
274
288
output_file.write(schema_definition)
275
289
276
290
## Transports
0 commit comments