Skip to content

Commit 4adc310

Browse files
author
Phil Sturgeon
committed
Last minute tweaks add to instance
1 parent 6d5b2f9 commit 4adc310

File tree

3 files changed

+1020
-8
lines changed

3 files changed

+1020
-8
lines changed

content/getting-specific-about-apis/source.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ GET /hats
431431
Link: <http://example.com/schemas/hats.json#>; rel=”describedby”
432432
```
433433

434-
Now you know what a collection of hats look like...
434+
Now clients know what a collection of hats look like...
435435

436436
---
437437

@@ -444,7 +444,7 @@ Now you know what a collection of hats look like...
444444
}
445445
```
446446

447-
And you know what a hat looks like...
447+
And now clients know what a hat looks like...
448448

449449
---
450450

@@ -835,15 +835,67 @@ Avoid writing careful OpenAPI-flavoured JSON Schema
835835

836836
Just write proper JSON Schema™!
837837

838+
[wework/json-schema-to-openapi-schema](https://github.com/wework/json-schema-to-openapi-schema)
839+
840+
---
841+
842+
```
843+
const toOpenApi = require('json-schema-to-openapi-schema');
844+
845+
const schema = {
846+
'$schema': 'http://json-schema.org/draft-04/schema#',
847+
type: ['string', 'null'],
848+
format: 'date-time',
849+
};
850+
851+
console.log(toOpenApi(schema));
852+
```
853+
854+
```
855+
{
856+
type: 'string',
857+
format: 'date-time',
858+
nullable: true
859+
}
860+
```
861+
838862
---
839863

864+
Validators like speccy fail...
840865

866+
```
867+
$ speccy lint docs/openapi.yml
868+
Specification schema is invalid.
869+
870+
#/paths/~1invalidations/post/requestBody/content/application~1json/properties/user_uuid
871+
expected Array [ 'string', 'null' ] to be a string
872+
expected Array [ 'string', 'null' ] to have type string
873+
expected 'object' to be 'string'
874+
```
841875

842-
TODO alt example
876+
---
877+
878+
But speccy has a `--json-schema` switch
879+
880+
```
881+
$ speccy lint docs/openapi.yml --json-schema
882+
Specification is valid, with 0 lint errors
883+
```
843884

844885
---
845886

846-
TODO Speccy example hack
887+
OpenAPI have a feature in "draft"
888+
889+
```
890+
schema:
891+
alternativeSchema:
892+
type: jsonSchema
893+
location: ./real-jsonschema.json
894+
```
895+
896+
(probably going in v3.1)
897+
898+
---
847899

848900
<!-- .slide: data-background="img/book.jpg" data-background-size="contain" -->
849901

instances/18-capitalone/getting-specific-about-apis/html/index.html

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
Link: <http://example.com/schemas/hats.json#>; rel=”describedby”
336336
```
337337

338-
Now you know what a collection of hats look like...
338+
Now clients know what a collection of hats look like...
339339
</script></section><section data-markdown><script type="text/template">
340340
```
341341
{
@@ -346,7 +346,7 @@
346346
}
347347
```
348348

349-
And you know what a hat looks like...
349+
And now clients know what a hat looks like...
350350
</script></section><section data-markdown><script type="text/template">
351351
``` js
352352
const Ajv = require('ajv');
@@ -652,13 +652,59 @@
652652
Avoid writing careful OpenAPI-flavoured JSON Schema
653653

654654
Just write proper JSON Schema™!
655+
656+
[wework/json-schema-to-openapi-schema](https://github.com/wework/json-schema-to-openapi-schema)
657+
</script></section><section data-markdown><script type="text/template">
658+
```
659+
const toOpenApi = require('json-schema-to-openapi-schema');
660+
661+
const schema = {
662+
'$schema': 'http://json-schema.org/draft-04/schema#',
663+
type: ['string', 'null'],
664+
format: 'date-time',
665+
};
666+
667+
console.log(toOpenApi(schema));
668+
```
669+
670+
```
671+
{
672+
type: 'string',
673+
format: 'date-time',
674+
nullable: true
675+
}
676+
```
655677
</script></section><section data-markdown><script type="text/template">
678+
Validators like speccy fail...
656679

680+
```
681+
$ speccy lint docs/openapi.yml
682+
Specification schema is invalid.
657683
658-
TODO alt example
684+
#/paths/~1invalidations/post/requestBody/content/application~1json/properties/user_uuid
685+
expected Array [ 'string', 'null' ] to be a string
686+
expected Array [ 'string', 'null' ] to have type string
687+
expected 'object' to be 'string'
688+
```
659689
</script></section><section data-markdown><script type="text/template">
660-
TODO Speccy example hack
690+
But speccy has a `--json-schema` switch
661691

692+
```
693+
$ speccy lint docs/openapi.yml --json-schema
694+
Specification is valid, with 0 lint errors
695+
```
696+
</script></section><section data-markdown><script type="text/template">
697+
OpenAPI have a feature in "draft"
698+
699+
```
700+
schema:
701+
alternativeSchema:
702+
type: jsonSchema
703+
location: ./real-jsonschema.json
704+
```
705+
706+
(probably going in v3.1)
707+
</script></section><section data-markdown><script type="text/template">
662708
<!-- .slide: data-background="img/book.jpg" data-background-size="contain" -->
663709

664710
<br/>

0 commit comments

Comments
 (0)