Skip to content

Commit fa88d8d

Browse files
committed
This will fix the migration system regarding the api/[controller] legacy
1 parent 78bfe39 commit fa88d8d

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

Modules/Intent.Modules.Metadata.WebApi/Intent.Metadata.WebApi.imodspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package>
33
<id>Intent.Metadata.WebApi</id>
4-
<version>4.6.0-pre.3</version>
4+
<version>4.6.0-pre.4</version>
55
<supportedClientVersions>[4.3.0-a, 5.0.0-a)</supportedClientVersions>
66
<summary>Support for describing Services in HTTP Web API terms.</summary>
77
<description>Support for describing Services in HTTP Web API terms.</description>

Modules/Intent.Modules.Metadata.WebApi/Intent.Modules.Metadata.WebApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5-
<Version>4.6.0-pre.3</Version>
5+
<Version>4.6.0-pre.4</Version>
66
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
77
<Authors>Intent Architect</Authors>
88
<Description>Extension methods for accessing the WebApi stereotypes.</Description>

Modules/Intent.Modules.Metadata.WebApi/Migrations/Migration_04_06_00_Pre_03.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class Migration_04_06_00_Pre_03 : IModuleMigration
1616
private const string HttpServiceSettingsStereotypeId = "c29224ec-d473-4b95-ad4a-ec55c676c4fd";
1717
private const string ServiceModelSpecializationTypeId = "b16578a5-27b1-4047-a8df-f0b783d706bd";
1818
private const string WebApiDefinitionPackageId = "0011387a-b122-45d7-9cdb-8e21b315ab9f";
19+
private const string RoutePropertyDefinitionId = "1e223bd0-7a72-435a-8741-a612d88e4a12";
1920

2021
public Migration_04_06_00_Pre_03(IApplicationConfigurationProvider configurationProvider)
2122
{
@@ -62,7 +63,7 @@ public void Up()
6263
[
6364
new StereotypePropertyPersistable
6465
{
65-
DefinitionId = "1e223bd0-7a72-435a-8741-a612d88e4a12",
66+
DefinitionId = RoutePropertyDefinitionId,
6667
Name = "Route",
6768
Value = "api/[controller]",
6869
IsActive = true
@@ -73,6 +74,28 @@ public void Up()
7374
element.Stereotypes.Add(httpServiceSettings);
7475
needsSave = true;
7576
}
77+
78+
if (httpServiceSettings is not null)
79+
{
80+
var routeProp = httpServiceSettings.Properties.FirstOrDefault(p => p.DefinitionId == RoutePropertyDefinitionId);
81+
if (routeProp is null)
82+
{
83+
routeProp = new StereotypePropertyPersistable
84+
{
85+
DefinitionId = RoutePropertyDefinitionId,
86+
Name = "Route",
87+
Value = "api/[controller]",
88+
IsActive = true
89+
};
90+
httpServiceSettings.Properties.Add(routeProp);
91+
needsSave = true;
92+
}
93+
else if (string.IsNullOrWhiteSpace(routeProp.Value))
94+
{
95+
routeProp.Value = "api/[controller]";
96+
needsSave = true;
97+
}
98+
}
7699
}
77100

78101
if (needsSave)
@@ -103,7 +126,7 @@ public void Down()
103126
var httpServiceSettings = element.Stereotypes.FirstOrDefault(p => p.DefinitionId == HttpServiceSettingsStereotypeId);
104127
if (httpServiceSettings != null)
105128
{
106-
var routeProperty = httpServiceSettings.Properties.FirstOrDefault(p => p.DefinitionId == "1e223bd0-7a72-435a-8741-a612d88e4a12");
129+
var routeProperty = httpServiceSettings.Properties.FirstOrDefault(p => p.DefinitionId == RoutePropertyDefinitionId);
107130
if (routeProperty != null && routeProperty.Value == "api/[controller]")
108131
{
109132
element.Stereotypes.Remove(httpServiceSettings);

0 commit comments

Comments
 (0)