• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

OpenAPIv2/H15-Aug-2019-

OpenAPIv3/H15-Aug-2019-

apps/H15-Aug-2019-

compiler/H15-Aug-2019-

discovery/H15-Aug-2019-

examples/H15-Aug-2019-

extensions/H15-Aug-2019-

generate-gnostic/H15-Aug-2019-

jsonschema/H15-Aug-2019-

jsonwriter/H15-Aug-2019-

linters/H15-Aug-2019-

plugins/H15-Aug-2019-

printer/H15-Aug-2019-

surface/H15-Aug-2019-

test/H15-Aug-2019-

tools/H15-Aug-2019-

.gitignoreH A D15-Aug-2019223

.travis-install.shH A D15-Aug-2019460

.travis.ymlH A D15-Aug-2019459

COMPILE-PROTOS.shH A D15-Aug-2019915

CONTRIBUTING.mdH A D15-Aug-20191.6 KiB

LICENSEH A D15-Aug-201911.1 KiB

MakefileH A D15-Aug-201990

README.mdH A D15-Aug-20194.2 KiB

gnostic.goH A D15-Aug-201919.1 KiB

gnostic_test.goH A D15-Aug-201911.3 KiB

go.modH A D15-Aug-2019183

go.sumH A D15-Aug-2019659

README.md

1[![Build Status](https://travis-ci.org/googleapis/gnostic.svg?branch=master)](https://travis-ci.org/googleapis/gnostic)
2
3# ⨁ gnostic
4
5This repository contains a Go command line tool which converts
6JSON and YAML [OpenAPI](https://github.com/OAI/OpenAPI-Specification)
7descriptions to and from equivalent Protocol Buffer representations.
8
9[Protocol Buffers](https://developers.google.com/protocol-buffers/)
10provide a language-neutral, platform-neutral, extensible mechanism
11for serializing structured data.
12**gnostic**'s Protocol Buffer models for the OpenAPI Specification
13can be used to generate code that includes data structures with
14explicit fields for the elements of an OpenAPI description.
15This makes it possible for developers to work with OpenAPI
16descriptions in type-safe ways, which is particularly useful
17in strongly-typed languages like Go and Swift.
18
19**gnostic** reads OpenAPI descriptions into
20these generated data structures, reports errors,
21resolves internal dependencies, and writes the results
22in a binary form that can be used in any language that is
23supported by the Protocol Buffer tools.
24A plugin interface simplifies integration with API
25tools written in a variety of different languages,
26and when necessary, Protocol Buffer OpenAPI descriptions
27can be reexported as JSON or YAML.
28
29**gnostic** compilation code and OpenAPI Protocol Buffer
30models are automatically generated from an
31[OpenAPI JSON Schema](https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json).
32Source code for the generator is in the [generate-gnostic](generate-gnostic) directory.
33
34## Disclaimer
35
36This is prerelease software and work in progress. Feedback and
37contributions are welcome, but we currently make no guarantees of
38function or stability.
39
40## Requirements
41
42**gnostic** can be run in any environment that supports [Go](http://golang.org)
43and the [Google Protocol Buffer Compiler](https://github.com/google/protobuf).
44
45## Installation
46
47The following instructions are for installing gnostic using
48[Go modules](https://blog.golang.org/using-go-modules),
49supported by Go 1.11 and later.
50
511. Get this package by downloading it with `git clone`.
52
53        git clone https://github.com/googleapis/gnostic
54        cd gnostic
55
562. [Optional] Build and run the gnostic compiler generator.
57This uses JSON schemas to generate Protocol Buffer language files
58that describes supported API specification formats and Go-language
59files of code that will read JSON or YAML API descriptions into
60the generated protocol buffer models.
61
62Pre-generated versions of these files are checked into the directories
63named OpenAPIv2, OpenAPIv3, and discovery.
64
65        go install ./generate-gnostic
66        generate-gnostic --v2
67        generate-gnostic --v3
68        generate-gnostic --discovery
69
703. Generate Protocol Buffer support code.
71This step requires a local installation of protoc, the Protocol Buffer Compiler,
72and the Go protoc plugin.
73You can get protoc [here](https://github.com/google/protobuf).
74You can install the plugin with this command:
75
76        go get github.com/golang/protobuf/protoc-gen-go
77
78Then use the following to compile the gnostic Protocol Buffer models:
79
80        ./COMPILE-PROTOS.sh
81
824. Build **gnostic**.
83
84        go install .
85
865. Run **gnostic**. This sample invocation creates a file in the current directory named "petstore.pb" that contains a binary
87Protocol Buffer description of a sample API.
88
89        gnostic --pb-out=. examples/v2.0/json/petstore.json
90
916. You can also compile files that you specify with a URL. Here's another way to compile the previous
92example. This time we're creating "petstore.text", which contains a textual representation of the
93Protocol Buffer description. This is mainly for use in testing and debugging.
94
95        gnostic --text-out=petstore.text https://raw.githubusercontent.com/googleapis/gnostic/master/examples/petstore.json
96
977. For a sample application, see apps/report.
98
99        go install ./apps/report
100        report petstore.pb
101
1028. **gnostic** supports plugins. Some are already implemented in the `plugins` directory.
103Others, like [gnostic-go-generator](https://github.com/googleapis/gnostic-go-generator),
104are separated into their own repositories.
105
106## Copyright
107
108Copyright 2017, Google Inc.
109
110## License
111
112Released under the Apache 2.0 license.
113