googleapis / disco-to-proto3-converter

Apache License 2.0
11 stars 11 forks source link

Errors with type ANY, and some well-formated camel cases #64

Open mxrch opened 2 years ago

mxrch commented 2 years ago

Environment details

Steps to reproduce

  1. Download an example Discovery Document here : https://people-pa.clients6.google.com/$discovery/rest
  2. Do java -jar disco-to-proto3-converter-0.0.1-SNAPSHOT-jar-with-dependencies.jar --discovery_doc_path=people-pa-v2.json --output_file_path=people-pa-v2.proto

I had 2 main errors : 1) The first one is that it doesn't like the type "ANY", it doesn't seems very popular, another discovery documents parser had the same error.. so as a workaround I changed it to a string, just to see if it pass The full error :

❯ java -jar disco-to-proto3-converter-0.0.1-SNAPSHOT-jar-with-dependencies.jar --discovery_doc_path=people-pa-v2.json --output_file_path=people-pa-v2.proto
Exception in thread "main" java.lang.IllegalArgumentException: Any type detected in schema: Schema "", type ANY
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.schemaToField(DocumentToProtoConverter.java:409)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.schemaToField(DocumentToProtoConverter.java:484)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.schemaToField(DocumentToProtoConverter.java:484)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.schemaToField(DocumentToProtoConverter.java:496)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.readSchema(DocumentToProtoConverter.java:101)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.<init>(DocumentToProtoConverter.java:65)
    at com.google.cloud.discotoproto3converter.ConverterApp.convert(ConverterApp.java:62)
    at com.google.cloud.discotoproto3converter.ConverterApp.convert(ConverterApp.java:75)
    at com.google.cloud.discotoproto3converter.DiscoToProto3ConverterApp.main(DiscoToProto3ConverterApp.java:29)

2) Then, it doesn't like the "people_pa" because it's not in camel case, understable we can change it even if it's from official APIs :

Exception in thread "main" java.lang.IllegalArgumentException: Name: identifier not in NO_CHECK camel: 'people_pa'
    at com.google.cloud.discotoproto3converter.disco.Name.validateCamel(Name.java:110)
    at com.google.cloud.discotoproto3converter.disco.Name.camelInternal(Name.java:76)
    at com.google.cloud.discotoproto3converter.disco.Name.anyCamel(Name.java:58)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.getRpcMessageName(DocumentToProtoConverter.java:747)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.readResources(DocumentToProtoConverter.java:613)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.<init>(DocumentToProtoConverter.java:66)
    at com.google.cloud.discotoproto3converter.ConverterApp.convert(ConverterApp.java:62)
    at com.google.cloud.discotoproto3converter.ConverterApp.convert(ConverterApp.java:75)
    at com.google.cloud.discotoproto3converter.DiscoToProto3ConverterApp.main(DiscoToProto3ConverterApp.java:29)

But then, it gives the same error on "context.consistencyOptions.levelOptions.exactTimestamp" and a lot of other ones, each time it has at least one dot in it:

Exception in thread "main" java.lang.IllegalArgumentException: Name: identifier not in NO_CHECK camel: 'context.consistencyOptions.levelOptions.exactTimestamp'
    at com.google.cloud.discotoproto3converter.disco.Name.validateCamel(Name.java:110)
    at com.google.cloud.discotoproto3converter.disco.Name.camelInternal(Name.java:76)
    at com.google.cloud.discotoproto3converter.disco.Name.anyCamel(Name.java:58)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.schemaToField(DocumentToProtoConverter.java:401)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.readResources(DocumentToProtoConverter.java:642)
    at com.google.cloud.discotoproto3converter.proto3.DocumentToProtoConverter.<init>(DocumentToProtoConverter.java:66)
    at com.google.cloud.discotoproto3converter.ConverterApp.convert(ConverterApp.java:62)
    at com.google.cloud.discotoproto3converter.ConverterApp.convert(ConverterApp.java:75)
    at com.google.cloud.discotoproto3converter.DiscoToProto3ConverterApp.main(DiscoToProto3ConverterApp.java:29)

It only pass if I remove all the dots from the concerned identifier !

noahdietz commented 2 years ago

Thanks @mxrch for the issue. This isn't an officially supported Google product as mentioned in the README, and it is used for very specific purposes atm. I've downgraded to P3 with that in mind.

@vam-google any thoughts on this?

vchudnov-g commented 10 months ago

For technical reasons, we cannot support arbitrary Any fields. However, we intend to support Any fields where the concrete types at run-tmie are only one of the types that occur in error_details.proto and when these Any fields only occur (at conversion time) within error.details fields. PR #102 is implementing this functionality.