wiremock / wiremock/WireMock.Net

Unable to add proto files from nested directories used in imports

Open
#1,262 19 comments 0 reactions 1 assignee View on GitHub

@StefH is already working on this.

Since Mar 13, 2025.

bug
Dominant language
C#
Stars
1.7k
Forks
240
Avg merge
5d 12h
Merged PRs (30d)
2

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.