Skip to content

Commit 414906d

Browse files
authored
Merge branch 'main' into bug/61-pattern-property
2 parents 84ee8d9 + 30931ee commit 414906d

File tree

6 files changed

+97
-5
lines changed

6 files changed

+97
-5
lines changed

src/Atc.Rest.ApiGenerator/ProjectSyntaxFactories/SyntaxMethodDeclarationFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading;
@@ -117,15 +117,15 @@ public static MethodDeclarationSyntax CreateInterfaceMethod(string parameterType
117117
{
118118
foreach (var pathParameter in globalPathParameters)
119119
{
120-
dictionary.Add(pathParameter.Name, pathParameter.Schema);
120+
dictionary.Add(pathParameter.Name.PascalCase(removeSeparators: true), pathParameter.Schema);
121121
}
122122
}
123123

124124
if (apiParameters != null)
125125
{
126126
foreach (var apiParameter in apiParameters)
127127
{
128-
dictionary.Add(apiParameter.Name, apiParameter.Schema);
128+
dictionary.Add(apiParameter.Name.PascalCase(removeSeparators: true), apiParameter.Schema);
129129
}
130130
}
131131

src/Atc.Rest.ApiGenerator/SyntaxFactories/SyntaxPropertyDeclarationFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ public static PropertyDeclarationSyntax CreateAuto(OpenApiParameter parameter, b
140140
var propertyDeclaration = parameter.Schema.Type == OpenApiDataTypeConstants.Array
141141
? CreateListAuto(
142142
parameter.Schema.Items.GetDataType(),
143-
parameter.Name.EnsureFirstCharacterToUpper())
143+
parameter.Name.PascalCase(removeSeparators: true))
144144
: CreateAuto(
145145
parameter.In,
146146
parameter.Schema.Nullable,
147147
parameter.Required,
148148
parameter.Schema.GetDataType(),
149-
parameter.Name.EnsureFirstCharacterToUpper(),
149+
parameter.Name.PascalCase(removeSeparators: true),
150150
useNullableReferenceTypes,
151151
parameter.Schema.Default);
152152

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: 3.0.0
2+
paths:
3+
'/':
4+
get:
5+
summary: Get
6+
description: Get
7+
operationId: get
8+
parameters:
9+
- name: fooBar
10+
in: header
11+
description: ''
12+
required: false
13+
schema:
14+
type: string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.CodeDom.Compiler;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
//------------------------------------------------------------------------------
5+
// This code was auto-generated by ApiGenerator x.x.x.x.
6+
//
7+
// Changes to this file may cause incorrect behavior and will be lost if
8+
// the code is regenerated.
9+
//------------------------------------------------------------------------------
10+
namespace TestProject.AtcTest.Contracts.Test
11+
{
12+
/// <summary>
13+
/// Parameters for operation request.
14+
/// Description: Get.
15+
/// Operation: Get.
16+
/// Area: Test.
17+
/// </summary>
18+
[GeneratedCode("ApiGenerator", "x.x.x.x")]
19+
public class GetParameters
20+
{
21+
[FromHeader(Name = "fooBar")]
22+
public string FooBar { get; set; }
23+
24+
/// <summary>
25+
/// Converts to string.
26+
/// </summary>
27+
public override string ToString()
28+
{
29+
return $"{nameof(FooBar)}: {FooBar}";
30+
}
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: 3.0.0
2+
paths:
3+
'/':
4+
get:
5+
summary: Get
6+
description: Get
7+
operationId: get
8+
parameters:
9+
- name: x-on-behalf-of
10+
in: header
11+
description: ''
12+
required: false
13+
schema:
14+
type: string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.CodeDom.Compiler;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
//------------------------------------------------------------------------------
5+
// This code was auto-generated by ApiGenerator x.x.x.x.
6+
//
7+
// Changes to this file may cause incorrect behavior and will be lost if
8+
// the code is regenerated.
9+
//------------------------------------------------------------------------------
10+
namespace TestProject.AtcTest.Contracts.Test
11+
{
12+
/// <summary>
13+
/// Parameters for operation request.
14+
/// Description: Get.
15+
/// Operation: Get.
16+
/// Area: Test.
17+
/// </summary>
18+
[GeneratedCode("ApiGenerator", "x.x.x.x")]
19+
public class GetParameters
20+
{
21+
[FromHeader(Name = "x-on-behalf-of")]
22+
public string XOnBehalfOf { get; set; }
23+
24+
/// <summary>
25+
/// Converts to string.
26+
/// </summary>
27+
public override string ToString()
28+
{
29+
return $"{nameof(XOnBehalfOf)}: {XOnBehalfOf}";
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)