DEV Community

Romny Duarte
Romny Duarte

Posted on

NET9: Swagger no compatible

Hola a Todos.

Desde NET8 y NET9 el componente de Swagger no funciona. Cuando creamos un proyecto viene predefinido habilitar la compatibilidad OpenApi.

Image description

Cuando revisamos la configuración del Program.cs observamos lo siguiente.

Image description

Si ejecutamos la aplicacion e intentamos navegar por /swagger obtenemos un error 404.

Image description

Para validar los endpoints es necesario abrir la ruta /openapi/v1.json

Image description

El componente Swagger es utilizado ampliamente en el mundo del desarrollo para realizar pruebas de los endpoints que estamos construyendo, es una herramienta bastante importante y necesaria.

Ahora bien, entonces como hacemos para probar los endpoints, muchos se preguntarán. De primera mano podemos usar Postman, en otra entrada del blog hablaremos de las opciones que tendremos para resolver esto.

En Postman basta con ir a la opción de Import, copiar toda la definición del file /openapi/v1.json. Con esto ya podremos probar nuestros endpoints.

Image description

Sl2

Romny

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️