Skip to content

Commit 5296239

Browse files
authored
refactor: Improve namespace (#29)
1 parent 4017b09 commit 5296239

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+59
-94
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,26 @@ APIWeaver is a powerful and lightweight library designed to provide a seamless i
1111

1212
## Work in progress
1313

14-
This project is currently under **active development**, with ongoing improvements, new features and potential API
15-
changes. I encourage you to try it out and provide feedback, but please be aware that the library is not yet stable.
14+
This project is currently under **active development**, with ongoing improvements, new features and potential API changes. I encourage you to try it out and provide feedback, but please be aware that the library is not yet stable.
1615

1716
## Getting Started
1817

1918
To get started with APIWeaver, you can install the NuGet package using your preferred package manager. In most cases, the package `APIWeaver.Swagger` is the one you are looking for.
2019

2120
1. Install the NuGet package
21+
2222
```shell
2323
dotnet add package APIWeaver.Swagger
2424
```
2525

2626
2. Add the using directive to your Program.cs file
27+
2728
```csharp
2829
using APIWeaver;
2930
```
3031

3132
3. Add the following lines to your `Program.cs` file.
33+
3234
```csharp
3335
builder.Services.AddApiWeaver();
3436

@@ -40,13 +42,11 @@ if (app.Environment.IsDevelopment())
4042
}
4143
```
4244

43-
That's it. You now have a fully functional Swagger UI in your application. The UI can be accessed by navigating to /swagger in your browser 🥳. A more detailed guide with more use cases can be found here.
44-
45+
That's it. You now have a fully functional Swagger UI in your application. The UI can be accessed by navigating to `/swagger` in your browser 🥳. A more detailed guide with more use cases can be found here.
4546

4647
## Contribution and Collaboration
4748

48-
Your contributions to this project are welcomed and encouraged. Your active involvement can significantly impact its
49-
success!
49+
Your contributions to this project are welcomed and encouraged. Your active involvement can significantly impact its success!
5050

5151
## License
5252

demo/APIWeaver.MinimalApi.Demo/APIWeaver.MinimalApi.Demo.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
<ItemGroup>
44
<ProjectReference Include="..\..\src\APIWeaver.Swagger\APIWeaver.Swagger.csproj"/>
5-
<ProjectReference Include="..\..\src\APIWeaver.OpenApi\APIWeaver.OpenApi.csproj" />
5+
<ProjectReference Include="..\..\src\APIWeaver.OpenApi\APIWeaver.OpenApi.csproj"/>
66
</ItemGroup>
77
<ItemGroup>
8-
<PackageReference Include="Bogus" Version="35.4.0" />
8+
<PackageReference Include="Bogus" Version="35.4.0"/>
99
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.1"/>
1010
</ItemGroup>
1111

demo/APIWeaver.MinimalApi.Demo/BookStore.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ public BookStore()
2020
_books = faker.Generate(10);
2121
}
2222

23-
public IEnumerable<Book> GetBooks()
24-
{
25-
return _books;
26-
}
23+
public IEnumerable<Book> GetBooks() => _books;
2724

2825
public Book? UpdateBook(Guid bookId, Book book)
2926
{
@@ -36,13 +33,14 @@ public IEnumerable<Book> GetBooks()
3633

3734
return null;
3835
}
39-
36+
4037
public Book? AddBook(Book book)
4138
{
4239
if (_books.Find(x => x.BookId == book.BookId) is not null)
4340
{
4441
return null;
4542
}
43+
4644
_books.Add(book);
4745
return book;
4846
}
@@ -60,7 +58,7 @@ public class Book
6058
public required int Pages { get; set; }
6159

6260
public BookType? BookType { get; set; }
63-
61+
6462
// [Obsolete]
6563
public Author? Author { get; set; }
6664
}
@@ -81,4 +79,4 @@ public class DummyResponse
8179
{
8280
[Required]
8381
public Author Author { get; set; } = null!;
84-
}
82+
}

demo/APIWeaver.MinimalApi.Demo/Program.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System.ComponentModel.DataAnnotations;
2+
using APIWeaver;
23
using APIWeaver.MinimalApi.Demo;
3-
using APIWeaver.OpenApi.Extensions;
4-
using APIWeaver.Schema.Models;
5-
using APIWeaver.Swagger.Extensions;
64
using Microsoft.AspNetCore.Mvc;
75
using JsonOptions = Microsoft.AspNetCore.Http.Json.JsonOptions;
86

@@ -39,10 +37,7 @@
3937
.WithOpenApi();
4038

4139

42-
bookstoreEndpoint.MapGet("/parameters", ([FromQuery] [Range(69,420, MinimumIsExclusive = true)] int age) =>
43-
{
44-
Results.Ok();
45-
});
40+
bookstoreEndpoint.MapGet("/parameters", ([FromQuery] [Range(69, 420, MinimumIsExclusive = true)] int age) => { Results.Ok(); });
4641
//
4742
// bookstoreEndpoint.MapGet("/", (BookStore bookstore) =>
4843
// {
@@ -63,7 +58,7 @@
6358
// return updateBook is null ? Results.NotFound() : Results.Ok(updateBook);
6459
// }).Produces<Book>()
6560
// .Produces(404);
66-
bookstoreEndpoint.MapPost("/dummy", ( [FromBody] [MinLength(4)] User[] friends) => Results.Ok()).Produces<DummyResponse>();
61+
bookstoreEndpoint.MapPost("/dummy", ([FromBody] [MinLength(4)] User[] friends) => Results.Ok()).Produces<DummyResponse>();
6762
// app.MapPost("/user", (User value, BookStore bookstore) => Results.Ok()).Produces<User>().WithOpenApi();
6863

6964

@@ -74,14 +69,13 @@ public class User
7469
{
7570
[AllowedValues("Peter", "Max")]
7671
public required string Name { get; set; }
77-
72+
7873
[AllowedValues(2, 3)]
7974
public required int Age { get; set; }
8075

8176
[MinLength(4)]
8277
public required string[] Friends { get; set; }
83-
84-
78+
8579

8680
// public required Dictionary<string, Book> Books { get; set; }
8781
}

src/APIWeaver.OpenApi/Extensions/ApplicationBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using APIWeaver.OpenApi.Middleware;
33
using Microsoft.AspNetCore.Builder;
44

5-
namespace APIWeaver.OpenApi.Extensions;
5+
namespace APIWeaver;
66

77
/// <summary>
88
/// Extension methods for <see cref="IApplicationBuilder" />.

src/APIWeaver.OpenApi/Extensions/OpenApiOptionsExtensions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using APIWeaver.Schema.Models;
2-
3-
namespace APIWeaver.OpenApi.Extensions;
1+
namespace APIWeaver;
42

53
/// <summary>
64
/// Extension methods for <see cref="OpenApiOptions" />.

src/APIWeaver.OpenApi/Extensions/OpenApiSchemaGeneratorOptionsExtensions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using APIWeaver.Schema.Models;
2-
3-
namespace APIWeaver.OpenApi.Extensions;
1+
namespace APIWeaver;
42

53
/// <summary>
64
/// Extension methods for <see cref="OpenApiSchemaGeneratorOptions" />-

src/APIWeaver.OpenApi/Extensions/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using APIWeaver.OpenApi.Middleware;
2-
using APIWeaver.Schema.Extensions;
32
using Microsoft.Extensions.DependencyInjection;
43
using Microsoft.Extensions.DependencyInjection.Extensions;
54

6-
namespace APIWeaver.OpenApi.Extensions;
5+
namespace APIWeaver;
76

87
/// <summary>
98
/// Contains extension methods for <see cref="IServiceCollection" />.

src/APIWeaver.OpenApi/Models/OpenApiDocumentDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.OpenApi.Interfaces;
22

3-
namespace APIWeaver.OpenApi.Models;
3+
namespace APIWeaver;
44

55
/// <summary>
66
/// Represents the definition of an OpenAPI document.

src/APIWeaver.OpenApi/Models/OpenApiGeneratorOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace APIWeaver.OpenApi.Models;
1+
namespace APIWeaver;
22

33
/// <summary>
44
/// Options for the OpenApi generator.

0 commit comments

Comments
 (0)