WireMock.Net: Unable to add proto files from nested directories used in imports

When I add proto definitions, the WireMockProtoFileResolver will only add the files if the filename (the first line comment in each proto file) does not contain invalid file name characters. However, when imports contain relative paths to other proto files, it fails to find them because they are not added.

I’m testing WireMock using the OpenTelemetry proto files, but they are organized in the following directory structure, which fails to work with WireMock. I’m manually parsing each proto file and injecting the filename as the first line comment in each file; however, it doesn’t work since the filename has to match the one in the imports, and I’m not allowed to use invalid filename characters, which the forward slash (/) is.

opentelemetry
└───proto
    ├───collector
    │   │
    │   ├───metrics
    │   │   └───v1
    │   │           metrics_service.proto
    │   │
    │   ├───profiles
    │   │   └───v1development
    │   │           profiles_service.proto
    │   │
    │   └───trace
    │       └───v1
    │               trace_service.proto
    │
    ├───common
    │   └───v1
    │           common.proto
    │
    ├───metrics
    │   └───v1
    │           metrics.proto
    │
    ├───profiles
    │   └───v1development
    │           profiles.proto
    │
    ├───resource
    │   └───v1
    │           resource.proto
    │
    └───trace
        └───v1
                trace.proto

Can I make this work, or do I need to find another tool for the job?

I was thinking about creating a custom IProtoFileResolver implementation, but the WireMockProtoFileResolver is hard coded in ProtoBufMatcher.DecodeAsync, and I don’t want to reimplement the entire thing as it seems like a missing feature in WireMock.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

I mean the request message. When I make a gRPC request to WireMock, I don’t see the JSON unless I set the transformer on the response.

OK, in that case, it;s better to create a new issue.