How to create an example of request object?
See original GitHub issueDo we support example values for request objects?
public async Task<ActionResult<IEnumerable<DummyDto>>> GetConfigurations(
[FromQuery] DummyQueryDto query) =>
Ok(await configurationRepository.GetQueryable()
.ProjectTo<DummyDto>(m_mapper.ConfigurationProvider)
.ApplyFilter(query.ToFilter())
.ApplySorting(query.ToSorter())
.ApplyPagination(query.Offset, query.Count).ToListAsync());
}
How do I supply example value for this DummyQueryDto
object into Swagger UI?
I use OpenApi, SwaggerUi3, AddOpenApiDocument - a really basic setup.
Is there a support for Swashbuckle.AspNetCore.Filters
?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Request Object | Branch CMS Documentation
The request object allows you to submit a POST or GET request to an URL. Essentially it provides a way to make REST...
Read more >Request - Web APIs - MDN Web Docs
Chrome Edge
Request Full support. Chrome42. more. Toggle history Full s...
Request() constructor Full support. Chrome40. footnote. Toggle history Full s...
init.priority parameter. Experimental Full support....
Read more >Request: Request() constructor - Web APIs - MDN Web Docs
The Request() constructor creates a new Request object.
Read more >ASP Request Object
The Request object is used to get information from a visitor. QueryString Collection Examples. Send query information when a user clicks on a...
Read more >Node.js - Request Object
Request Object Properties ; 1. req.app. This property holds a reference to the instance of the express application that is using the middleware....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve created a custom
IOperationProcessor
that can create example responses based on attributes on the controller actions e.g.The first attribute is the ASP.NET Core-provided attribute, which gives the overall shape of the response; the second response is a custom attribute, where the
CountryExampleGenerator
mentioned exposes anIEnumerable
method that returns sample data:The custom
IOperationProcessor
then resolves those attributes when generating the OpenApi document (and generates a standard set of responses for e.g. 400 Bad Request, 404 Not Found. However, at the moment, I don’t know exactly where to place the final rendered result. On the older Swagger spec, it was on theexample
property of the response, but with OpenApi, it’s in the schema definition (https://swagger.io/docs/specification/2-0/adding-examples/). Any suggestions as to how I can close that particular circle? I’m happy to post the code for my processor if I can get that working.I think it would make sense to add an attribute to specify this out of the box. However what example object/schema would we use? I think we should only support OpenAPI schemas directly (not ReDoc custom formats).