From 4faeea27b0d11cace6ff89c9c15a6844be88d42b Mon Sep 17 00:00:00 2001 From: "Chris H (CruftMaster)" Date: Mon, 24 Apr 2017 09:14:59 +0100 Subject: [PATCH] Moving sample protos around, adding some docs --- Makefile | 10 ++++++++++ README.md | 20 +++++++++---------- generate-samples.sh | 7 +++++-- protoc_gen_jsonschema_test.go | 2 +- samples/jsonschema/README.md | 1 - testdata/README.md | 6 ++++++ .../proto/ArrayOfMessages.proto | 0 .../proto/ArrayOfObjects.proto | 0 .../proto/ArrayOfPrimitives.proto | 0 {samples => testdata}/proto/Enumception.proto | 0 .../proto/ImportedEnum.proto | 0 .../proto/NestedMessage.proto | 0 .../proto/NestedObject.proto | 0 .../proto/PayloadMessage.proto | 0 .../proto/SeveralEnums.proto | 0 .../proto/SeveralMessages.proto | 0 16 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 Makefile delete mode 100644 samples/jsonschema/README.md create mode 100644 testdata/README.md rename {samples => testdata}/proto/ArrayOfMessages.proto (100%) rename {samples => testdata}/proto/ArrayOfObjects.proto (100%) rename {samples => testdata}/proto/ArrayOfPrimitives.proto (100%) rename {samples => testdata}/proto/Enumception.proto (100%) rename {samples => testdata}/proto/ImportedEnum.proto (100%) rename {samples => testdata}/proto/NestedMessage.proto (100%) rename {samples => testdata}/proto/NestedObject.proto (100%) rename {samples => testdata}/proto/PayloadMessage.proto (100%) rename {samples => testdata}/proto/SeveralEnums.proto (100%) rename {samples => testdata}/proto/SeveralMessages.proto (100%) diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..465639e1 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +default: darwin linux windows + +darwin: + GOOS=darwin GOARCH=amd64 go build -o protoc-gen-jsonschema.darwin-amd64 + +linux: + GOOS=linux GOARCH=amd64 go build -o protoc-gen-jsonschema.linux-amd64 + +windows: + GOOS=windows GOARCH=amd64 go build -o protoc-gen-jsonschema.windows-amd64.exe diff --git a/README.md b/README.md index f00ad7dd..539b951b 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,13 @@ Links Sample protos (for testing) --------------------------- -* Proto with a simple (flat) structure: [samples.PayloadMessage](PayloadMessage.proto) -* Proto containing a nested object (defined internally): [ssamples.NestedObject](NestedObject.proto) -* Proto containing a nested message (defined in a different proto file): [samples.NestedMessage](NestedMessage.proto) -* Proto containing an array of a primitive types (string, int): [samples.ArrayOfPrimitives](ArrayOfPrimitives.proto) -* Proto containing an array of objects (internally defined): [samples.ArrayOfObjects](ArrayOfObjects.proto) -* Proto containing an array of messages (defined in a different proto file): [samples.ArrayOfMessage](ArrayOfMessage.proto) -* Proto containing multi-level enums (flat and nested and arrays): [samples.Enumception](Enumception.proto) -* Proto containing a stand-alone enum: [samples.ImportedEnum](ImportedEnum.proto) -* Proto containing 2 stand-alone enums: [samples.FirstEnum, samples.SecondEnum](SeveralEnums.proto) -* Proto containing 2 messages: [samples.FirstMessage, samples.SecondMessage](SeveralMessages.proto) +* Proto with a simple (flat) structure: [samples.PayloadMessage](testdata/proto/PayloadMessage.proto) +* Proto containing a nested object (defined internally): [samples.NestedObject](testdata/proto/NestedObject.proto) +* Proto containing a nested message (defined in a different proto file): [samples.NestedMessage](testdata/proto/NestedMessage.proto) +* Proto containing an array of a primitive types (string, int): [samples.ArrayOfPrimitives](testdata/proto/ArrayOfPrimitives.proto) +* Proto containing an array of objects (internally defined): [samples.ArrayOfObjects](testdata/proto/ArrayOfObjects.proto) +* Proto containing an array of messages (defined in a different proto file): [samples.ArrayOfMessage](testdata/proto/ArrayOfMessage.proto) +* Proto containing multi-level enums (flat and nested and arrays): [samples.Enumception](testdata/proto/Enumception.proto) +* Proto containing a stand-alone enum: [samples.ImportedEnum](testdata/proto/ImportedEnum.proto) +* Proto containing 2 stand-alone enums: [samples.FirstEnum, samples.SecondEnum](testdata/proto/SeveralEnums.proto) +* Proto containing 2 messages: [samples.FirstMessage, samples.SecondMessage](testdata/proto/SeveralMessages.proto) diff --git a/generate-samples.sh b/generate-samples.sh index 789586be..b7ab7ac8 100755 --- a/generate-samples.sh +++ b/generate-samples.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash -PROTO_DIR="samples/proto" -JSONSCHEMA_DIR="samples/jsonschema" +PROTO_DIR="testdata/proto" +JSONSCHEMA_DIR="jsonschemas" PATH=$PATH:. +# Ensure that the JSONSchema directory exists +mkdir -p $JSONSCHEMA_DIR + # Generate all of the files: for PROTO_FILE in `ls ${PROTO_DIR}/*.proto` do diff --git a/protoc_gen_jsonschema_test.go b/protoc_gen_jsonschema_test.go index 48176a41..15c06aa4 100644 --- a/protoc_gen_jsonschema_test.go +++ b/protoc_gen_jsonschema_test.go @@ -16,7 +16,7 @@ import ( var ( protocBinary = "/bin/protoc" - sampleProtoDirectory = "samples/proto" + sampleProtoDirectory = "testdata/proto" sampleProtos = make(map[string]SampleProto) ) diff --git a/samples/jsonschema/README.md b/samples/jsonschema/README.md deleted file mode 100644 index 5a5f1a2e..00000000 --- a/samples/jsonschema/README.md +++ /dev/null @@ -1 +0,0 @@ -This is where JSON-Schema files should be written to \ No newline at end of file diff --git a/testdata/README.md b/testdata/README.md new file mode 100644 index 00000000..f617cdbd --- /dev/null +++ b/testdata/README.md @@ -0,0 +1,6 @@ +Test Data +========= + +This package contains constants two sets of test data: +1) Proto definitions for various test cases. These define different types of messages and proto payloads which the test suite will attempt to compile. +2) The GoLang files contain consts which define the exact JSONSchemas which are expected to be generated by the tests. diff --git a/samples/proto/ArrayOfMessages.proto b/testdata/proto/ArrayOfMessages.proto similarity index 100% rename from samples/proto/ArrayOfMessages.proto rename to testdata/proto/ArrayOfMessages.proto diff --git a/samples/proto/ArrayOfObjects.proto b/testdata/proto/ArrayOfObjects.proto similarity index 100% rename from samples/proto/ArrayOfObjects.proto rename to testdata/proto/ArrayOfObjects.proto diff --git a/samples/proto/ArrayOfPrimitives.proto b/testdata/proto/ArrayOfPrimitives.proto similarity index 100% rename from samples/proto/ArrayOfPrimitives.proto rename to testdata/proto/ArrayOfPrimitives.proto diff --git a/samples/proto/Enumception.proto b/testdata/proto/Enumception.proto similarity index 100% rename from samples/proto/Enumception.proto rename to testdata/proto/Enumception.proto diff --git a/samples/proto/ImportedEnum.proto b/testdata/proto/ImportedEnum.proto similarity index 100% rename from samples/proto/ImportedEnum.proto rename to testdata/proto/ImportedEnum.proto diff --git a/samples/proto/NestedMessage.proto b/testdata/proto/NestedMessage.proto similarity index 100% rename from samples/proto/NestedMessage.proto rename to testdata/proto/NestedMessage.proto diff --git a/samples/proto/NestedObject.proto b/testdata/proto/NestedObject.proto similarity index 100% rename from samples/proto/NestedObject.proto rename to testdata/proto/NestedObject.proto diff --git a/samples/proto/PayloadMessage.proto b/testdata/proto/PayloadMessage.proto similarity index 100% rename from samples/proto/PayloadMessage.proto rename to testdata/proto/PayloadMessage.proto diff --git a/samples/proto/SeveralEnums.proto b/testdata/proto/SeveralEnums.proto similarity index 100% rename from samples/proto/SeveralEnums.proto rename to testdata/proto/SeveralEnums.proto diff --git a/samples/proto/SeveralMessages.proto b/testdata/proto/SeveralMessages.proto similarity index 100% rename from samples/proto/SeveralMessages.proto rename to testdata/proto/SeveralMessages.proto