@@ -6,6 +6,59 @@ For installation or development instructions, see:
66
77## Introduction
88
9- This ` dhall-openapi ` package provides an OpenAPI to Dhall compiler.
9+ This ` dhall-openapi ` package provides a compiler from OpenAPI 2.0 (a.k.a. Swagger)
10+ to Dhall.
1011
11- The ` openapi-to-dhall ` executable generates the Dhall types from an OpenAPI specification.
12+ The ` openapi-to-dhall ` executable generates the Dhall types from an OpenAPI
13+ specification.
14+
15+ The simplest way to use the executable is:
16+
17+ ``` bash
18+ $ openapi-to-dhall openapi.json
19+ ```
20+
21+ … where ` openapi.json ` could be any OpenAPI 2.0 document.
22+
23+ For example,
24+ [ ` dhall-kubernetes ` ] ( https://github.com/dhall-lang/dhall-kubernetes ) generates
25+ Dhall bindings for each version of the Kubernetes API by running
26+ ` openapi-to-dhall ` on a ` swagger.json ` file like
27+ [ this one] ( https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json ) .
28+
29+ The ` openapi-to-dhall ` command generates the following directories and files:
30+
31+ * ` ./types ` - This directory contains one Dhall type for each definition in the
32+ OpenAPI Definitions object
33+
34+ In other words, this generates one Dhall type for each sub-key of the
35+ ` "definitions" ` key
36+
37+ * ` ./defaults ` - This directory contains the corresponding default values for
38+ each Dhall type in the ` ./types ` directory
39+
40+ * ` ./schemas ` - This directory contains the corresponding "schemas" for each
41+ definition
42+
43+ A schema is a value suitable for Dhall's record completion operator (i.e.
44+ ` :: ` ) containing both the type and the default value bundled together. Each
45+ of the schemas contained in this directory just re-exports the corresponding
46+ type and default value from the other two directories.
47+
48+ * ` ./types.dhall ` - A record which re-exports all of the types in the ` ./types `
49+ directory
50+
51+ * ` ./defaults.dhall ` - A record which re-exports all of the defaults in the
52+ ` ./defaults ` directory
53+
54+ * ` ./schemas.dhall ` - A record which re-exports all of the schemas in the
55+ ` ./schemas ` directory
56+
57+ * ` ./typesUnion.dhall ` - A record which exports a union type with one
58+ alternative for each type
59+
60+ * ` ./package.dhall ` - A record which re-exports ` schemas.dhall ` and
61+ ` typesUnion.dhall `
62+
63+ For example, see the
64+ [ Dhall code generated for Kubernetes version 1.21] ( https://github.com/dhall-lang/dhall-kubernetes/tree/master/1.21 ) .
0 commit comments