Skip to content

Commit 9711965

Browse files
authored
Merge pull request #216 from atc-net/hotfix/apioptions
Ensure proper reading of ApiOptions for AspNetOutputType and SwaggerMode
2 parents 57f97ec + 0debb5a commit 9711965

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,12 @@ By using these options, you can effectively organize generated files into meanin
390390

391391
The `projectSuffixName` extend `projectName` like the example:
392392

393-
| projectName | projectSuffixName | Generated project name | Reson |
394-
|-------------|-------------------|------------------------|-------|
393+
| projectName | projectSuffixName | Generated project name | Reason |
394+
|-------------|-------------------|------------------------|----------------------------|
395395
| PetStore | | PetStore.Api.Generated | default is `Api.Generated` |
396-
| PetStore | MyApi | PetStore.MyApi | |
397-
| PetStore | Foo.Api | PetStore.Foo.Api | |
398-
| PetStore | Bar-Api | PetStore.Bar.Api | |
396+
| PetStore | MyApi | PetStore.MyApi | |
397+
| PetStore | Foo.Api | PetStore.Foo.Api | |
398+
| PetStore | Bar-Api | PetStore.Bar.Api | |
399399

400400
## PetStore Example
401401

src/Atc.Rest.ApiGenerator.CLI/ApiOptionsHelper.cs

+4-10
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ private static void ApplyGeneratorOverrides(
132132
{
133133
if (settings is BaseServerCommandSettings serverCommandSettings)
134134
{
135-
if (serverCommandSettings.AspNetOutputType.IsSet ||
135+
if (serverCommandSettings.AspNetOutputType.IsSet &&
136136
serverCommandSettings.AspNetOutputType.Value != apiOptions.Generator.AspNetOutputType)
137137
{
138138
apiOptions.Generator.AspNetOutputType = serverCommandSettings.AspNetOutputType.Value;
139139
}
140140

141-
if (serverCommandSettings.SwaggerThemeMode.IsSet ||
141+
if (serverCommandSettings.SwaggerThemeMode.IsSet &&
142142
serverCommandSettings.SwaggerThemeMode.Value != apiOptions.Generator.SwaggerThemeMode)
143143
{
144144
apiOptions.Generator.SwaggerThemeMode = serverCommandSettings.SwaggerThemeMode.Value;
@@ -149,10 +149,7 @@ private static void ApplyGeneratorOverrides(
149149
apiOptions.Generator.Response.UseProblemDetailsAsDefaultBody = serverCommandSettings.UseProblemDetailsAsDefaultResponseBody;
150150
}
151151

152-
if (serverCommandSettings.ProjectPrefixName is not null)
153-
{
154-
apiOptions.Generator.ProjectName = serverCommandSettings.ProjectPrefixName;
155-
}
152+
apiOptions.Generator.ProjectName = serverCommandSettings.ProjectPrefixName;
156153

157154
if (serverCommandSettings.EndpointsLocation is not null &&
158155
serverCommandSettings.EndpointsLocation.IsSet)
@@ -215,10 +212,7 @@ private static void ApplyGeneratorOverrides(
215212
apiOptions.Generator.Response.UseProblemDetailsAsDefaultBody = clientApiCommandSettings.UseProblemDetailsAsDefaultResponseBody;
216213
}
217214

218-
if (clientApiCommandSettings.ProjectPrefixName is not null)
219-
{
220-
apiOptions.Generator.ProjectName = clientApiCommandSettings.ProjectPrefixName;
221-
}
215+
apiOptions.Generator.ProjectName = clientApiCommandSettings.ProjectPrefixName;
222216

223217
if (clientApiCommandSettings.RemoveNamespaceGroupSeparatorInGlobalUsings)
224218
{

0 commit comments

Comments
 (0)