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

..03-May-2022-

OpenAPIv2/H29-Jul-2017-15,47813,661

OpenAPIv3/H29-Jul-2017-19,29016,621

apps/H29-Jul-2017-967874

compiler/H29-Jul-2017-594420

examples/H29-Jul-2017-3,5563,529

extensions/H29-Jul-2017-515390

generate-gnostic/H29-Jul-2017-2,5312,133

jsonschema/H29-Jul-2017-1,7511,454

jsonwriter/H29-Jul-2017-173139

plugins/H29-Jul-2017-23,24918,269

printer/H29-Jul-2017-6232

test/H29-Jul-2017-1,5111,495

tools/H29-Jul-2017-11166

.gitignoreH A D29-Jul-2017106 1413

.travis-install.shH A D29-Jul-2017838 3714

.travis.ymlH A D29-Jul-2017766 4436

COMPILE-PROTOS.shH A D29-Jul-2017935 3210

CONTRIBUTING.mdH A D29-Jul-20171.6 KiB3628

LICENSEH A D29-Jul-201711.1 KiB204169

MakefileH A D29-Jul-2017573 1613

README.mdH A D29-Jul-20174.1 KiB10473

gnostic.goH A D29-Jul-201716.4 KiB557434

gnostic_test.goH A D29-Jul-201710.9 KiB454369

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
471. Get this package by downloading it with `go get`.
48
49        go get github.com/googleapis/gnostic
50
512. [Optional] Build and run the compiler generator.
52This uses the OpenAPI JSON schema to generate a Protocol Buffer language file
53that describes the OpenAPI specification and a Go-language file of code that
54will read a JSON or YAML OpenAPI representation into the generated protocol
55buffers. Pre-generated versions of these files are in the OpenAPIv2 directory.
56
57        cd $GOPATH/src/github.com/googleapis/gnostic/generate-gnostic
58        go install
59        cd ..
60        generate-gnostic --v2
61
623. [Optional] Generate Protocol Buffer support code.
63A pre-generated version of this file is checked into the OpenAPIv2 directory.
64This step requires a local installation of protoc, the Protocol Buffer Compiler.
65You can get protoc [here](https://github.com/google/protobuf).
66
67        ./COMPILE-PROTOS.sh
68
694. [Optional] Rebuild **gnostic**. This is only necessary if you've performed steps
702 or 3 above.
71
72        go install github.com/googleapis/gnostic
73
745. Run **gnostic**. This will create a file in the current directory named "petstore.pb" that contains a binary
75Protocol Buffer description of a sample API.
76
77        gnostic --pb-out=. examples/petstore.json
78
796. You can also compile files that you specify with a URL. Here's another way to compile the previous
80example. This time we're creating "petstore.text", which contains a textual representation of the
81Protocol Buffer description. This is mainly for use in testing and debugging.
82
83        gnostic --text-out=petstore.text https://raw.githubusercontent.com/googleapis/gnostic/master/examples/petstore.json
84
857. For a sample application, see apps/report.
86
87        go install github.com/googleapis/gnostic/apps/report
88        report petstore.pb
89
908. **gnostic** supports plugins. This builds and runs a sample plugin
91that reports some basic information about an API. The "-" causes the plugin to
92write its output to stdout.
93
94        go install github.com/googleapis/gnostic/plugins/gnostic-go-sample
95        gnostic examples/petstore.json --go-sample-out=-
96
97## Copyright
98
99Copyright 2017, Google Inc.
100
101## License
102
103Released under the Apache 2.0 license.
104