Open nomad-software opened 2 years ago
@nomad-software Were you able to resolve this issue for your use case, or do you know what caused this error?
Nope, it was never resolved. I had to remove the offending parts by had from the Json file before conversion. Luckily I didn't need those particular endpoints.
Thanks! I found that if I use a recent version of gnostic to create a .pb
binary, I can get the .proto
output by running gnostic-grpc -input petstore.pb
, for example.
Thanks for the suggestion but that doesn't work on the original file mentioned.
I believe to have found source of this issue.
Definition like this:
"DataResult": {
"properties": {
"object": {
"additionalProperties": {
"$ref": "#/definitions/DataResult"
},
"description": "Object value",
"example": "",
"type": "object"
},
"string": {
"type": "string"
},
},
"type": "object"
}
Is represented by gnostic-grpc like that:
message Object {
map<string, DataResult> additional_properties = 1;
}
message DataResult {
string string = 1;
Object object = 2;
}
To do that, gnostic internally generates a type to store object
field data.
Note that it uses namedSchema.Name
as a name for a new type. In this case it happens to be an object
(look at field name).
Later, gnostic-rpc begins processing a field with name object
and type object
:
Since type object
is reserved it is not resolved there.
But later on NativeType
of a field is used as a name of a referenced proto message (resulting in api_package.object
):
Obviously, this results in an invalid proto file since it does not contains a definition for a api_package.object
message.
I've fixed the issue for me by changing the first snippet to prefix generated type name with it's containing type name.
fieldTypeName := fmt.Sprintf("%s_%s", name, namedSchema.Name)
fieldInfo := b.buildFromSchemaOrReference(fieldTypeName, namedSchema.Value)
makeFieldAndAppendToType(fieldInfo, schemaType, namedSchema.Name)
Thanks! I found that if I use a recent version of gnostic to create a
.pb
binary, I can get the.proto
output by runninggnostic-grpc -input petstore.pb
, for example.
Same issue. This path worked for me. Thanks for the help! Strange that the invocation of gnostic-grpc
as plugin gives different results.
I'm trying to convert the following Json file: https://github.com/oracle/hospitality-api-docs/blob/main/rest-api-specs/property/lov.json
Using this command:
and i'm getting this error:
If I then try the
--resolve-refs
option like this:I get another slightly different error:
There's another file that has problems too: https://github.com/oracle/hospitality-api-docs/blob/main/rest-api-specs/property/fofcfg.json
but the rest convert correctly. Any ideas on what is happening here as the Json files seem to be valid?
Thanks.