Support OData #319

Closed
opened 2025-12-29 15:20:39 +01:00 by adam · 2 comments
Owner

Originally created by @xadvfh on GitHub (Dec 15, 2020).

Is your feature request related to a problem? Please describe.
Is there a way to support OData with the responses that we stub out in WireMock.Net?

Describe the solution you'd like
Given I stub a request to return a specific response
When a user requests the data with a OData query
Then the response should only include the data the query specifies

Describe alternatives you've considered
Stubbing every single query used

Is your feature request supported by WireMock (java version)? Please provide details.
Only via stubbing each query

Additional context
#72 talks about stubbing a specific OData query but I'm wondering if this is something that could be built in.

Originally created by @xadvfh on GitHub (Dec 15, 2020). **Is your feature request related to a problem? Please describe.** Is there a way to support [OData](https://www.odata.org/) with the responses that we stub out in WireMock.Net? **Describe the solution you'd like** Given I stub a request to return a specific response When a user requests the data with a OData query Then the response should only include the data the query specifies **Describe alternatives you've considered** Stubbing every single query used **Is your feature request supported by [WireMock (java version)](https://www.wiremock.org)? Please provide details.** Only via stubbing each query **Additional context** #72 talks about stubbing a specific OData query but I'm wondering if this is something that could be built in.
adam added the wontfix label 2025-12-29 15:20:39 +01:00
adam closed this issue 2025-12-29 15:20:39 +01:00
Author
Owner

@StefH commented on GitHub (Dec 15, 2020):

OData is just a specification.

With WireMock.Net you can stub any request and response.

Or do you have a different question?

@StefH commented on GitHub (Dec 15, 2020): OData is just a specification. With WireMock.Net you can stub any request and response. Or do you have a different question?
Author
Owner

@xadvfh commented on GitHub (Dec 15, 2020):

I guess I was wondering if there is a way for wiremock to autogenerate the stubs based on a request. I'm not even sure if this is possible but here is what I had floating around in my head.

Assuming the response is a json object, if there was a stub like this:

server
	.Given(Request.Create()
		.WithPath($"/personal/api/v2/Accounts/11234567890")
		.UsingGet()
		.StubODataQueries());
	.RespondWith(Response.Create()
		.WithStatusCode(200)
		.WithHeader(ResponseConstants.ContentTypeKey, ResponseConstants.ContentTypeJson)
		.WithBodyAsJson(CreateResponse(accountSection)));

When a request matches that path but has an OData query attached to it, it would take the response that the user specified in WithBodyAsJson and create a new one based on the OData query.

@xadvfh commented on GitHub (Dec 15, 2020): I guess I was wondering if there is a way for wiremock to autogenerate the stubs based on a request. I'm not even sure if this is possible but here is what I had floating around in my head. Assuming the response is a json object, if there was a stub like this: ``` c# server .Given(Request.Create() .WithPath($"/personal/api/v2/Accounts/11234567890") .UsingGet() .StubODataQueries()); .RespondWith(Response.Create() .WithStatusCode(200) .WithHeader(ResponseConstants.ContentTypeKey, ResponseConstants.ContentTypeJson) .WithBodyAsJson(CreateResponse(accountSection))); ``` When a request matches that path but has an OData query attached to it, it would take the response that the user specified in `WithBodyAsJson` and create a new one based on the OData query.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#319