Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add response codes to all endpoints, so that these are listed in swagger #584

Closed
Jossilainen opened this issue Feb 21, 2024 · 0 comments · Fixed by #673
Closed

Add response codes to all endpoints, so that these are listed in swagger #584

Jossilainen opened this issue Feb 21, 2024 · 0 comments · Fixed by #673
Assignees
Labels

Comments

@Jossilainen
Copy link
Contributor

Jossilainen commented Feb 21, 2024

Expected outcome

It is informative for frontend to know what response codes each endpoint can give.

Business Value / Developer Experience

Example: POST api/onboarded-contexts

Response codes:

Name Description
201 Created Created
401 Unauthorized User not authorized to create
403 Forbidden User not authorized to create
409 Conflict Context already exist
404 NotFound Context type not found

Snipped from fusion core:

using Fusion.AspNetCore.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Fusion.Services.Core.AspNetCore;

public class FusionProducesOkResponseTypeAttribute() : ProducesResponseTypeAttribute(StatusCodes.Status200OK);

public class FusionProducesCreatedResponseTypeAttribute() : ProducesResponseTypeAttribute(StatusCodes.Status201Created);

public class FusionProducesAcceptedResponseTypeAttribute() : ProducesResponseTypeAttribute(StatusCodes.Status202Accepted);

public class FusionProducesNoContentResponseTypeAttribute() : ProducesResponseTypeAttribute(typeof(void), StatusCodes.Status204NoContent);

public class FusionProducesBadRequestResponseTypeAttribute() : ProducesResponseTypeAttribute(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest);

public class FusionProducesUnauthorizedResponseTypeAttribute() : ProducesResponseTypeAttribute(typeof(void), StatusCodes.Status401Unauthorized);

public class FusionProducesForbiddenResponseTypeAttribute() : ProducesResponseTypeAttribute(typeof(FusionForbiddenResponse), StatusCodes.Status403Forbidden);

public class FusionProducesNotFoundResponseTypeAttribute() : ProducesResponseTypeAttribute(typeof(ProblemDetails), StatusCodes.Status404NotFound);

public class FusionProducesConflictResponseTypeAttribute() : ProducesResponseTypeAttribute(typeof(ProblemDetails), StatusCodes.Status409Conflict);

public class FusionProducesFailedDependencyResponseTypeAttribute() : ProducesResponseTypeAttribute(typeof(ProblemDetails), StatusCodes.Status424FailedDependency);

User Acceptance Tests (UAT)

NA

Environments

All testing of issues are done in project-portal-test

For Backend use these

@Jossilainen Jossilainen changed the title Add response codes to all endpoints, so that these are listed in swagger for each endpoint Add response codes to all endpoints, so that these are listed in swagger Feb 21, 2024
@Jossilainen Jossilainen self-assigned this Jul 9, 2024
@Jossilainen Jossilainen linked a pull request Aug 6, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant