Skip to content

Commit fadc32e

Browse files
committed
fix: Move loading api
1 parent 3fb6357 commit fadc32e

21 files changed

+578
-560
lines changed

.editorconfig

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,25 @@ indent_size = 4
1515
indent_style = space
1616

1717
# New line preferences
18-
end_of_line = unset
18+
end_of_line = crlf
1919
insert_final_newline = false
20+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
21+
dotnet_style_coalesce_expression = true:suggestion
22+
dotnet_style_null_propagation = true:suggestion
23+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
24+
dotnet_style_prefer_auto_properties = true:silent
25+
dotnet_style_object_initializer = true:suggestion
26+
dotnet_style_collection_initializer = true:suggestion
27+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
28+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
29+
dotnet_style_prefer_conditional_expression_over_return = true:silent
30+
dotnet_style_explicit_tuple_names = true:suggestion
31+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
32+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
33+
dotnet_style_prefer_compound_assignment = true:suggestion
34+
dotnet_style_prefer_simplified_interpolation = true:suggestion
35+
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
36+
dotnet_style_namespace_match_folder = true:suggestion
2037

2138
#### Build files ####
2239

@@ -50,10 +67,10 @@ file_header_template = This Source Code Form is subject to the terms of the MIT
5067
#### .NET Coding Conventions ####
5168

5269
# this. and Me. preferences
53-
dotnet_style_qualification_for_event = false:warning
54-
dotnet_style_qualification_for_field = true:warning
55-
dotnet_style_qualification_for_method = false:warning
56-
dotnet_style_qualification_for_property = false:warning
70+
dotnet_style_qualification_for_event = false:none
71+
dotnet_style_qualification_for_field = false:none
72+
dotnet_style_qualification_for_method = false:none
73+
dotnet_style_qualification_for_property = false:none
5774

5875
# Language keywords vs BCL types preferences
5976
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
@@ -99,13 +116,13 @@ csharp_style_var_for_built_in_types = false:warning
99116
csharp_style_var_when_type_is_apparent = false:warning
100117

101118
# Expression-bodied members
102-
csharp_style_expression_bodied_accessors = false:silent
119+
csharp_style_expression_bodied_accessors = true:silent
103120
csharp_style_expression_bodied_constructors = false:silent
104-
csharp_style_expression_bodied_indexers = false:silent
121+
csharp_style_expression_bodied_indexers = true:silent
105122
csharp_style_expression_bodied_lambdas = true:silent
106123
csharp_style_expression_bodied_methods = false:silent
107124
csharp_style_expression_bodied_operators = false:silent
108-
csharp_style_expression_bodied_properties = false:silent
125+
csharp_style_expression_bodied_properties = true:silent
109126

110127
# Pattern matching preferences
111128
csharp_style_prefer_pattern_matching = true:suggestion
@@ -119,9 +136,9 @@ csharp_style_conditional_delegate_call = true:suggestion
119136
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
120137

121138
# Code-block preferences
122-
csharp_prefer_braces = true:suggestion
123-
csharp_using_directive_placement = outside_namespace:warning
124-
csharp_style_namespace_declarations = file_scoped:warning
139+
csharp_prefer_braces = true:silent
140+
csharp_using_directive_placement = outside_namespace:silent
141+
csharp_style_namespace_declarations = block_scoped:silent
125142
csharp_style_unused_value_assignment_preference = discard_variable:none
126143
csharp_style_unused_value_expression_statement_preference = discard_variable:none
127144
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:warning
@@ -147,7 +164,7 @@ csharp_indent_block_contents = true
147164
csharp_indent_braces = false
148165
csharp_indent_case_contents = true
149166
csharp_indent_case_contents_when_block = false
150-
csharp_indent_labels = no_change
167+
csharp_indent_labels = one_less_than_current
151168
csharp_indent_switch_labels = true
152169

153170
# Space preferences
@@ -387,3 +404,10 @@ dotnet_diagnostic.SA1629.severity = none
387404
dotnet_diagnostic.SA1633.severity = none
388405
dotnet_diagnostic.SA1634.severity = none
389406
dotnet_diagnostic.SA1652.severity = none
407+
csharp_prefer_simple_using_statement = true:suggestion
408+
csharp_style_prefer_method_group_conversion = true:silent
409+
csharp_style_prefer_top_level_statements = true:silent
410+
csharp_style_prefer_primary_constructors = true:suggestion
411+
csharp_prefer_system_threading_lock = true:suggestion
412+
csharp_style_expression_bodied_local_functions = false:silent
413+
csharp_style_prefer_null_check_over_type_check = true:suggestion

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66
<PropertyGroup>
77
<Version>1.0.0</Version>
8-
<AssemblyVersion>1.0.0</AssemblyVersion>
9-
<PackageVersion>1.0.0-preview.5</PackageVersion>
8+
<AssemblyVersion>$(Version)</AssemblyVersion>
9+
<PackageVersion>$(Version)-preview.6</PackageVersion>
1010
</PropertyGroup>
1111
<PropertyGroup>
1212
<Company>lepo.co</Company>

Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@
8181
<Compile Include="$(GeneratedSkipLocalsInitFile)" />
8282
</ItemGroup>
8383
</Target>
84+
8485
</Project>

src/OpenApi.Client.Cli/Commands/GenerateCommand.cs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,45 +37,19 @@ public override async Task<int> ExecuteAsync(CommandContext context, GenerateCom
3737

3838
await using FileStream fileStream = new(settings.File, FileMode.Open, FileAccess.Read);
3939

40-
ReadResult readResult = await OpenApiDocument.LoadAsync(
41-
fileStream,
42-
format: null,
43-
settings: null,
44-
cancellationToken: cancellationTokenSource.Token
45-
);
46-
47-
if (readResult.Diagnostic?.Errors.Count > 0)
48-
{
49-
foreach (OpenApiError? serializationResultError in readResult.Diagnostic.Errors)
50-
{
51-
AnsiConsole.MarkupLine($"[red]Error:[/] {serializationResultError.Message}");
52-
}
53-
54-
return -1;
55-
}
56-
57-
if (readResult.Document is null)
58-
{
59-
AnsiConsole.MarkupLine("[red]Error:[/] Serialized JSON returned empty API.");
60-
61-
return -2;
62-
}
63-
6440
ClientGenerator generator = new(
65-
readResult.Document,
6641
new GeneratorData
6742
{
6843
NamespaceName = settings.Namespace,
6944
ClassName = settings.ClassName,
7045
Access = Accessibility.Public,
7146
SerializationTool = SerializationTool.SystemTextJson,
72-
Location = Location.None,
73-
SelectedFile = "",
47+
Source = fileStream,
7448
Templates = null,
7549
}
7650
);
7751

78-
GenerationResult generatorResult = generator.Generate();
52+
GenerationResult generatorResult = await generator.GenerateAsync(cancellationTokenSource.Token);
7953

8054
//OpenApiContract contract = OpenApiContractParser.Parse(
8155
// settings.Namespace,

0 commit comments

Comments
 (0)