Skip to content

Commit

Permalink
feat: refactor SchemaModelService to update appMetadata when creating…
Browse files Browse the repository at this point in the history
… new data model (#14209)

Co-authored-by: Erling Hauan <[email protected]>
  • Loading branch information
standeren and ErlingHauan authored Dec 11, 2024
1 parent fc6bfbb commit 94be9b9
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 118 deletions.
10 changes: 5 additions & 5 deletions backend/src/Designer/Controllers/DatamodelsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,17 @@ public async Task<IActionResult> AddXsd(string org, string repository, [FromForm
Request.EnableBuffering();
Guard.AssertArgumentNotNull(theFile, nameof(theFile));

string fileName = GetFileNameFromUploadedFile(theFile);
Guard.AssertFileExtensionIsOfType(fileName, ".xsd");
string fileNameWithExtension = GetFileNameFromUploadedFile(theFile);
Guard.AssertFileExtensionIsOfType(fileNameWithExtension, ".xsd");

string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);

var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, repository, developer);
var fileStream = theFile.OpenReadStream();
await _modelNameValidator.ValidateModelNameForNewXsdSchemaAsync(fileStream, fileName, editingContext);
string jsonSchema = await _schemaModelService.BuildSchemaFromXsd(editingContext, fileName, theFile.OpenReadStream(), cancellationToken);
await _modelNameValidator.ValidateModelNameForNewXsdSchemaAsync(fileStream, fileNameWithExtension, editingContext);
string jsonSchema = await _schemaModelService.BuildSchemaFromXsd(editingContext, fileNameWithExtension, theFile.OpenReadStream(), cancellationToken);

return Created(Uri.EscapeDataString(fileName), jsonSchema);
return Created(Uri.EscapeDataString(fileNameWithExtension), jsonSchema);
}

/// <summary>
Expand Down
Loading

0 comments on commit 94be9b9

Please sign in to comment.