ASP.NET Minimal API with OpenAPI

ASP.NET Minimal API with OpenAPI

Guides writing ASP.NET Minimal API endpoints with typed requests and responses and thorough OpenAPI documentation using .NET 9 features.

Skill files1 file
SKILL.md42 lines
1
---
2
name: aspnet-minimal-api-openapi
3
description: 'Create ASP.NET Minimal API endpoints with proper OpenAPI documentation'
4
---
5
6
# ASP.NET Minimal API with OpenAPI
7
8
Your goal is to help me create well-structured ASP.NET Minimal API endpoints with correct types and comprehensive OpenAPI/Swagger documentation.
9
10
## API Organization
11
12
- Group related endpoints using `MapGroup()` extension
13
- Use endpoint filters for cross-cutting concerns
14
- Structure larger APIs with separate endpoint classes
15
- Consider using a feature-based folder structure for complex APIs
16
17
## Request and Response Types
18
19
- Define explicit request and response DTOs/models
20
- Create clear model classes with proper validation attributes
21
- Use record types for immutable request/response objects
22
- Use meaningful property names that align with API design standards
23
- Apply `[Required]` and other validation attributes to enforce constraints
24
- Use the ProblemDetailsService and StatusCodePages to get standard error responses
25
26
## Type Handling
27
28
- Use strongly-typed route parameters with explicit type binding
29
- Use `Results<T1, T2>` to represent multiple response types
30
- Return `TypedResults` instead of `Results` for strongly-typed responses
31
- Leverage C# 10+ features like nullable annotations and init-only properties
32
33
## OpenAPI Documentation
34
35
- Use the built-in OpenAPI document support added in .NET 9
36
- Define operation summary and description
37
- Add operationIds using the `WithName` extension method
38
- Add descriptions to properties and parameters with `[Description()]`
39
- Set proper content types for requests and responses
40
- Use document transformers to add elements like servers, tags, and security schemes
41
- Use schema transformers to apply customizations to OpenAPI schemas
42

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…