Skip to content

Commit

Permalink
docs: openapi documentation (#14458)
Browse files Browse the repository at this point in the history
Co-authored-by: Erling Hauan <[email protected]>
Co-authored-by: Tomas Engebretsen <[email protected]>
  • Loading branch information
3 people authored Feb 3, 2025
1 parent 66dbe10 commit 9fc8700
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 9 deletions.
2 changes: 2 additions & 0 deletions backend/src/Designer/Controllers/AppDevelopmentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace Altinn.Studio.Designer.Controllers
/// <summary>
/// Controller containing actions that concerns app-development
/// </summary>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("designer/api/{org}/{app:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/app-development")]
Expand Down Expand Up @@ -57,6 +58,7 @@ public AppDevelopmentController(IAppDevelopmentService appDevelopmentService, IR
/// Default action for the designer.
/// </summary>
/// <returns>default view for the app builder.</returns>
[HttpGet]
[Route("/editor/{org}/{app:regex(^[[a-z]]+[[a-zA-Z0-9-]]+[[a-zA-Z0-9]]$)}/{*AllValues}")]
public async Task<IActionResult> Index(string org, string app)
{
Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/ConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Altinn.Studio.Designer.Controllers
/// <summary>
/// Controller exposing endpoints that handle metadata in config.json
/// </summary>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("designer/api/{org}/{app:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/config")]
Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/DatamodelsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace Altinn.Studio.Designer.Controllers
/// <summary>
/// Controller containing all actions related to data modelling
/// </summary>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("designer/api/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/datamodels")]
Expand Down
3 changes: 1 addition & 2 deletions backend/src/Designer/Controllers/EnvironmentsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;


namespace Altinn.Studio.Designer.Controllers
{
/// <summary>
/// This is the API controller for functionality related to environments.
/// </summary>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]

public class EnvironmentsController : ControllerBase
{
private readonly IEnvironmentsService _environmentsService;
Expand Down
1 change: 0 additions & 1 deletion backend/src/Designer/Controllers/FeedbackFormController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Altinn.Studio.Designer.TypedHttpClients.Slack;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;

namespace Altinn.Studio.Designer.Controllers;

Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/ImageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Altinn.Studio.Designer.Controllers;
/// <summary>
/// Controller containing actions related to images
/// </summary>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("designer/api/{org}/{app:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/images")]
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Designer/Controllers/OptionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public async Task<ActionResult<List<RefToOptionListSpecifier>>> GetOptionListsRe
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[Route("{optionsListId}")]
public async Task<ActionResult<Dictionary<string, List<Option>>>> CreateOrOverwriteOptionsList(string org, string repo, [FromRoute] string optionsListId, [FromBody] List<Option> payload, CancellationToken cancellationToken = default)
public async Task<ActionResult<List<Option>>> CreateOrOverwriteOptionsList(string org, string repo, [FromRoute] string optionsListId, [FromBody] List<Option> payload, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/OrganizationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Altinn.Studio.Designer.Controllers
/// <summary>
/// This is the API controller for functionality related to repositories.
/// </summary>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("designer/api/orgs")]
Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/PolicyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Altinn.Studio.Designer.Controllers
{
[ApiController]
[Route("/designer/api/{org}/{app:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/policy")]
public class PolicyController : ControllerBase
{
Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/Preview/DataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace Altinn.Studio.Designer.Controllers.Preview
{
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("{org:regex(^(?!designer))}/{app:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/instances/{partyId}/{instanceGuid}/data")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Altinn.Studio.Designer.Controllers.Preview;

[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("{org:regex(^(?!designer))}/{app:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/instances")]
Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/PreviewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace Altinn.Studio.Designer.Controllers
/// <param name="textsService">Texts Service</param>
/// <param name="appDevelopmentService">App Development Service</param>
/// Factory class that knows how to create types of <see cref="AltinnGitRepository"/>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
// Uses regex to not match on designer since the call from frontend to get the iframe for app-frontend,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Altinn.Studio.Designer.Controllers
/// <summary>
/// Controller containing actions that concerns app-development
/// </summary>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("designer/api/{org}/{repo:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/process-modelling")]
Expand Down
12 changes: 8 additions & 4 deletions backend/src/Designer/Controllers/RepositoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Altinn.Studio.Designer.Controllers
/// <remarks>
/// Initializes a new instance of the <see cref="RepositoryController"/> class.
/// </remarks>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("designer/api/repos")]
Expand Down Expand Up @@ -55,14 +56,17 @@ public RepositoryController(IGitea giteaWrapper, ISourceControl sourceControl, I
}

/// <summary>
/// Returns a list over repositories
/// Returns a list over repositories specified by search parameters
/// </summary>
/// <param name="searchOptions">The search params</param>
/// <returns>List of repositories that user has access to.</returns>
/// <remarks>
/// All parameters create the search parameters
/// </remarks>
/// <returns>List of filtered repositories that user has access to.</returns>
[HttpGet]
[Route("search")]
public async Task<SearchResults> Search(SearchOptions searchOptions)
public async Task<SearchResults> Search([FromQuery] string keyword, [FromQuery] int uId, [FromQuery] string sortBy, [FromQuery] string order, [FromQuery] int page, [FromQuery] int limit)
{
SearchOptions searchOptions = new SearchOptions { Keyword = keyword, UId = uId, SortBy = sortBy, Order = order, Page = page, Limit = limit };
SearchResults repositories = await _giteaApi.SearchRepo(searchOptions);
return repositories;
}
Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/TextController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Altinn.Studio.Designer.Controllers
/// <summary>
/// Controller for resources
/// </summary>
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("designer/api/{org}/{app:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/text")]
Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Altinn.Studio.Designer.Controllers
/// <summary>
/// API controller for User functionality
/// </summary>
[ApiController]
[Authorize]
[Route("designer/api/user")]
public class UserController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public async Task Tag_ReturnsCreateOkd()
DataElement dataElement = await createDataElement(instance, "datamodel");
string dataPath = $"{Org}/{AppV4}/instances/{PartyId}/{instance.Id}/data/{dataElement.Id}/tags";
using HttpRequestMessage httpRequestMessageTag = new(HttpMethod.Post, dataPath);
httpRequestMessageTag.Content = new StringContent("{\"tag\":\"test\"}", System.Text.Encoding.UTF8, "application/json");
httpRequestMessageTag.Content = new StringContent("\"test\"", System.Text.Encoding.UTF8, "application/json");
using HttpResponseMessage responseTag = await HttpClient.SendAsync(httpRequestMessageTag);
Assert.Equal(HttpStatusCode.Created, responseTag.StatusCode);
}
Expand Down

0 comments on commit 9fc8700

Please sign in to comment.