forked from grpc-ecosystem/grpc-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated protoc-gen-swagger to output enum path parameters correctly
Updated protoc-gen-grpc-gateway to handle enum path parameters Regenerated examples Added pathenum proto for an externally imported enum example and verification Added enum_helper.go to handle the lack of enum support in the swagger-codegen-cli 2.2.2 for Go, see swagger-api/swagger-codegen#5635 Fixed browser integration test cases Updated bazel config Fixed last, faulty bazel config
- Loading branch information
Marcus Rosén
committed
Aug 28, 2018
1 parent
e679739
commit a21f07f
Showing
26 changed files
with
717 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package abe | ||
|
||
import ( | ||
pbexamplepb "github.com/grpc-ecosystem/grpc-gateway/examples/proto/examplepb" | ||
pbpathenum "github.com/grpc-ecosystem/grpc-gateway/examples/proto/pathenum" | ||
"github.com/grpc-ecosystem/grpc-gateway/runtime" | ||
) | ||
|
||
// String returns a string representation of "NumericEnum" | ||
func (e ExamplepbNumericEnum) String() string { | ||
return pbexamplepb.NumericEnum_ONE.String() | ||
} | ||
|
||
// UnmarshalJSON does a no-op unmarshal to ExamplepbNumericEnum. | ||
// It just validates that the input is sane. | ||
func (e ExamplepbNumericEnum) UnmarshalJSON(b []byte) error { | ||
return unmarshalJSONEnum(b, pbexamplepb.NumericEnum_value) | ||
} | ||
|
||
// String returns a string representation of "MessagePathEnum" | ||
func (e MessagePathEnumNestedPathEnum) String() string { | ||
return pbpathenum.MessagePathEnum_JKL.String() | ||
} | ||
|
||
// UnmarshalJSON does a no-op unmarshal to MessagePathEnumNestedPathEnum. | ||
// It just validates that the input is sane. | ||
func (e MessagePathEnumNestedPathEnum) UnmarshalJSON(b []byte) error { | ||
return unmarshalJSONEnum(b, pbpathenum.MessagePathEnum_NestedPathEnum_value) | ||
} | ||
|
||
// String returns a string representation of "PathEnum" | ||
func (e PathenumPathEnum) String() string { | ||
return pbpathenum.PathEnum_DEF.String() | ||
} | ||
|
||
// UnmarshalJSON does a no-op unmarshal to PathenumPathEnum. | ||
// It just validates that the input is sane. | ||
func (e PathenumPathEnum) UnmarshalJSON(b []byte) error { | ||
return unmarshalJSONEnum(b, pbpathenum.PathEnum_value) | ||
} | ||
|
||
func unmarshalJSONEnum(b []byte, enumValMap map[string]int32) error { | ||
val := string(b[1 : len(b)-1]) | ||
_, err := runtime.Enum(val, enumValMap) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
examples/clients/abe/message_path_enum_nested_path_enum.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* A Bit of Everything | ||
* | ||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
* | ||
* OpenAPI spec version: 1.0 | ||
* Contact: none@example.com | ||
* Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
*/ | ||
|
||
package abe | ||
|
||
type MessagePathEnumNestedPathEnum struct { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* A Bit of Everything | ||
* | ||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
* | ||
* OpenAPI spec version: 1.0 | ||
* Contact: none@example.com | ||
* Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
*/ | ||
|
||
package abe | ||
|
||
type PathenumPathEnum struct { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.