question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Protobuf Support

See original GitHub issue

Is there any official support for protobuf endpoints ?

Using the latest version, 2.9.0 it enters in an infinite loop mapping internal protobuf things…

2018-06-06 10:02:45.099 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Adding type Lcom/google/protobuf/UnknownFieldSet; for parameter defaultInstanceForType
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Recursively resolving dependencies for type Lcom/google/protobuf/UnknownFieldSet;
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Adding type Lcom/google/protobuf/UnknownFieldSet$Parser; for parameter parserForType
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Recursively resolving dependencies for type Lcom/google/protobuf/UnknownFieldSet$Parser;
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Adding type Lcom/google/protobuf/DescriptorProtos$OneofOptionsOrBuilder; for parameter optionsOrBuilder
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Recursively resolving dependencies for type Lcom/google/protobuf/DescriptorProtos$OneofOptionsOrBuilder;
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Adding type Ljava/util/Map<Lcom/google/protobuf/Descriptors$FieldDescriptor;Ljava/lang/Object;>; for parameter allFields
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Recursively resolving dependencies for value type Ljava/lang/Object;
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Marking base type Ljava/lang/Object; as seen
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Adding type Lcom/google/protobuf/Message; for parameter defaultInstanceForType
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Recursively resolving dependencies for type Lcom/google/protobuf/Message;
2018-06-06 10:02:45.100 DEBUG 7010 --- [           main] s.d.s.DefaultModelDependencyProvider     : Adding type Ljava/util/Map<Lcom/google/protobuf/Descriptors$FieldDescriptor;Ljava/lang/Object;>; for parameter allFields

On the other hand, registering the ProtobufModule provided by https://github.com/HubSpot/jackson-datatype-protobuf

@Override
  public void onApplicationEvent(ObjectMapperConfigured objectMapperConfigured) {
    objectMapperConfigured.getObjectMapper().registerModule(new ProtobufModule());
  }

I ended up with with empty generated models …

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
xehonkcommented, Jun 18, 2018

We were able to get make it work (for our current simple api) with a module for jackson: https://github.com/innogames/springfox-protobuf

3reactions
cdmbrcommented, Jun 21, 2018

@xehonk we were able to use your module ! thanks a lot !

I’ve just changed the following method to support better diferent property names (since we use snake_case in your protos, BeanPropertyDefinition was expecting a lowerCamelCase property )

private Map<String, FieldDescriptor> getDescriptorForType(Class<?> type) {
        try {
          Descriptor invoke = (Descriptor) type.getMethod("getDescriptor").invoke(null);
          Map<String, FieldDescriptor> descriptorsForType = new HashMap<>();
          invoke
              .getFields()
              .stream()
              .forEach(
                  fieldDescriptor -> {
                    descriptorsForType.put(fieldDescriptor.getName(), fieldDescriptor);
                    descriptorsForType.put(fieldDescriptor.getJsonName(), fieldDescriptor);
                  });
          return descriptorsForType;
        } catch (Exception e) {
          LOGGER.error("Error getting protobuf descriptor for swagger.", e);
          return new HashMap<>();
        }
      }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently Asked Questions | Protocol Buffers
This document answers some frequently asked questions about the Protocol Buffers open source project. If you have a question that isn't answered here, ......
Read more >
Protobuf and Null Support - ITNEXT
Let me answer your question, with a question of my own. What does it mean to be null? The problem is null can...
Read more >
Problems getting fastpython protobuf support - Stack Overflow
I see that there is supposed to be support for creating python wrappers to the C++ generated protobuf readers.
Read more >
Protocol Buffers - Wikipedia
Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to ......
Read more >
Inheriting protobuf messages - Google Groups
This question is regarding inheritance in C++ protobuf library. I will explain by giving a concrete example. ... Protobuf doesn't support inheritance.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found