Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ omitted apart from one that was explicitly set to `null` or to a value. A contro

## Layout

| Project | Target | Purpose |
| --- | --- | --- |
| `PTrampert.SimplePatch` | net8.0 | Core package: `Optional<T>`, `IPatchObject<T>`, `PatchClassBuilder`, JSON converters, validation |
| `PTrampert.SimplePatch.Schema` | net8.0 | `PatchSchemaTransform`: the OpenAPI schema rewrite shared by both integration packages |
| `PTrampert.SimplePatch.Swashbuckle` | net8.0 | Swashbuckle schema filter |
| `PTrampert.SimplePatch.OpenApi` | net10.0 | `Microsoft.AspNetCore.OpenApi` schema transformer. It is net10.0 only because it needs `GetOrCreateSchemaAsync`. |
| `*.Test` | match their subject | NUnit test projects, one per shipped package (except `Schema`, which the integration tests cover) |
| `PTrampert.SimplePatch.Test.External` | net8.0 | A second assembly for the core tests, holding non-public types they use from another assembly. Not packed. |
| `PTrampert.SimplePatch.Sample` | net8.0 | Sample web API, not packed |
Every project targets `net10.0` only. Don't add another target framework without an issue for it.

| Project | Purpose |
| --- | --- |
| `PTrampert.SimplePatch` | Core package: `Optional<T>`, `IPatchObject<T>`, `PatchClassBuilder`, JSON converters, validation |
| `PTrampert.SimplePatch.Schema` | `PatchSchemaTransform`: the OpenAPI schema rewrite shared by both integration packages |
| `PTrampert.SimplePatch.Swashbuckle` | Swashbuckle schema filter |
| `PTrampert.SimplePatch.OpenApi` | `Microsoft.AspNetCore.OpenApi` schema transformer |
| `*.Test` | NUnit test projects, one per shipped package (except `Schema`, which the integration tests cover) |
| `PTrampert.SimplePatch.Test.External` | A second assembly for the core tests, holding non-public types they use from another assembly. Not packed. |
| `PTrampert.SimplePatch.Sample` | Sample web API, not packed |

Docs are built with docfx (`docfx.json`, `index.md`, `docs/`). The API reference is generated
into `api/` from XML doc comments. `README.md` is packed into every NuGet package, so it is the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!--
net10.0 only: the transformer needs OpenApiSchemaTransformerContext.GetOrCreateSchemaAsync
to obtain the source model's schema, which .NET 9 does not have. See the OpenAPI proposal
in docs/proposals for the .NET 9 story.
-->
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!--
net8.0 so that both integration packages can consume it: PTrampert.SimplePatch.Swashbuckle
targets net8.0 and PTrampert.SimplePatch.OpenApi targets net10.0.
-->
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
non-public property type from an assembly that, unlike the test project, grants no access
to the generated patch classes. -->
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
1 change: 0 additions & 1 deletion PTrampert.SimplePatch/Optional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/// Default constructor for Optional.
/// Initializes an Optional with no value, meaning HasValue will be false.
/// </summary>
public Optional()

Check warning on line 40 in PTrampert.SimplePatch/Optional.cs

View workflow job for this annotation

GitHub Actions / dotnet-library / build-test / build-test

Non-nullable property 'Value' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 40 in PTrampert.SimplePatch/Optional.cs

View workflow job for this annotation

GitHub Actions / dotnet-library / build-test / build-test

Non-nullable property 'Value' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
{
HasValue = false;
}
Expand All @@ -64,7 +64,6 @@
/// <returns>True if the Optional has a value and the values are equal. False otherwise.</returns>
public static bool operator ==(Optional<T> left, T right)
{
ArgumentNullException.ThrowIfNull(left);
if (!left.HasValue)
return false;
if (left.Value != null)
Expand Down
5 changes: 2 additions & 3 deletions PTrampert.SimplePatch/PTrampert.SimplePatch.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -27,8 +27,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageReference Include="System.CodeDom" Version="9.0.8" />
<PackageReference Include="System.Text.Json" Version="9.0.8" />
<PackageReference Include="System.CodeDom" Version="10.0.12" />
</ItemGroup>

</Project>
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ and your object contains additional properties besides `name`, PTrampert.SimpleP
- Documents PATCH routes properly in OpenAPI, via optional Swashbuckle and
`Microsoft.AspNetCore.OpenApi` integration packages.

## Requirements

Every package targets `net10.0`, so your application needs .NET 10 or later. The last releases that
run on .NET 8 and .NET 9 are the 1.x line.

## Getting Started
A full sample project is available in the [PTrampert.SimplePatch.Samples](./PTrampert.SimplePatch.Sample)
* Install the library via NuGet:
Expand Down Expand Up @@ -167,7 +172,7 @@ dotnet add package PTrampert.SimplePatch.Swashbuckle
builder.Services.AddSwaggerGen(options => options.AddSimplePatchSchemas());
```

### Microsoft.AspNetCore.OpenApi (.NET 10+)
### Microsoft.AspNetCore.OpenApi

```bash
dotnet add package PTrampert.SimplePatch.OpenApi
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ dotnet add package PTrampert.SimplePatch
}));
```

On .NET 10 and later, `PTrampert.SimplePatch.OpenApi` does the same for the built-in generator:
`PTrampert.SimplePatch.OpenApi` does the same for the built-in generator:

```csharp
builder.Services.AddOpenApi(options => options.AddSimplePatchSchemas());
Expand Down
4 changes: 4 additions & 0 deletions docs/proposals/openapi-contract-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ net9.0 as proposed in §3. Obtaining the source model's schema from a transforme
have. Supporting .NET 9 would need a different mechanism, and .NET 9's OpenAPI.NET 1.6 object model
would also fork the shared transform. Swashbuckle covers .NET 8 and 9 in the meantime.

Since 2.0, every package targets net10.0 only
([#76](https://github.com/PaulTrampert/PTrampert.SimplePatch/issues/76)), so the target frameworks
in §3 and §4 describe the 1.x packages.

## 1. The problem

A route that takes `[FromBody] IPatchObject<PersonWriteModel>` is documented from the
Expand Down
Loading