-
-
Notifications
You must be signed in to change notification settings - Fork 158
OpenAPI: Generalization of naming conventions #1123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2e847ab
Fix failing test when run in parallel, respect naming convention as s…
maurei c4b2d17
Add client and swagger doc tests
maurei 9f9f1ab
Added annotations to JsonApiObject types
maurei 842a71b
Added tests for pascal and camelcase and introduced fixes to make the…
maurei f6c01f2
Fix CI
maurei b43807a
Process review feedback
maurei 4a128ad
ignore generated swagger.json files
maurei 45dd549
Restore formatting in csproj files
maurei 531ebd8
Additional self-review round
maurei 061c357
remove BeJson overload
maurei c14587c
Merge base test suite and text context, move swagger.json to swagger.…
maurei e835b33
Process feedback
maurei c7eff0a
Process feedback
maurei c6d2641
cleanup code
maurei 9f3f665
Fix irregularities in test file
maurei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using JetBrains.Annotations; | ||
|
||
// We cannot rely on generating ApiException as soon as we are generating multiple clients, see https://github.com/RicoSuter/NSwag/issues/2839#issuecomment-776647377. | ||
// Instead, we configure NSwag to point to the exception below in the generated code. | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace JsonApiDotNetCore.OpenApi.Client.Exceptions; | ||
|
||
[UsedImplicitly(ImplicitUseTargetFlags.Members)] | ||
public sealed class ApiException : Exception | ||
{ | ||
public int StatusCode { get; } | ||
|
||
public string? Response { get; } | ||
|
||
public IReadOnlyDictionary<string, IEnumerable<string>> Headers { get; } | ||
|
||
public ApiException(string message, int statusCode, string? response, IReadOnlyDictionary<string, IEnumerable<string>> headers, Exception innerException) | ||
: base($"{message}\n\nStatus: {statusCode}\nResponse: \n{response ?? "(null)"}", innerException) | ||
{ | ||
StatusCode = statusCode; | ||
Response = response; | ||
Headers = headers; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...DotNetCore.OpenApi/JsonApiObjects/Documents/NullableResourceIdentifierResponseDocument.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Text.Json.Serialization; | ||
using JetBrains.Annotations; | ||
using JsonApiDotNetCore.OpenApi.JsonApiObjects.Links; | ||
using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; | ||
using JsonApiDotNetCore.Resources; | ||
|
||
namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; | ||
|
||
// Types in the current namespace are never touched by ASP.NET ModelState validation, therefore using a non-nullable reference type for a property does not | ||
// imply this property is required. Instead, we use [Required] explicitly, because this is how Swashbuckle is instructed to mark properties as required. | ||
[UsedImplicitly(ImplicitUseTargetFlags.Members)] | ||
internal sealed class NullableResourceIdentifierResponseDocument<TResource> : NullableSingleData<ResourceIdentifierObject<TResource>> | ||
where TResource : IIdentifiable | ||
{ | ||
[JsonPropertyName("meta")] | ||
public IDictionary<string, object> Meta { get; set; } = null!; | ||
|
||
[JsonPropertyName("jsonapi")] | ||
public JsonapiObject Jsonapi { get; set; } = null!; | ||
|
||
[Required] | ||
[JsonPropertyName("links")] | ||
public LinksInResourceIdentifierDocument Links { get; set; } = null!; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/PrimaryResourceResponseDocument.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Text.Json.Serialization; | ||
using JetBrains.Annotations; | ||
using JsonApiDotNetCore.OpenApi.JsonApiObjects.Links; | ||
using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; | ||
using JsonApiDotNetCore.Resources; | ||
|
||
namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; | ||
|
||
// Types in the current namespace are never touched by ASP.NET ModelState validation, therefore using a non-nullable reference type for a property does not | ||
// imply this property is required. Instead, we use [Required] explicitly, because this is how Swashbuckle is instructed to mark properties as required. | ||
[UsedImplicitly(ImplicitUseTargetFlags.Members)] | ||
internal sealed class PrimaryResourceResponseDocument<TResource> : SingleData<ResourceObjectInResponse<TResource>> | ||
where TResource : IIdentifiable | ||
{ | ||
[JsonPropertyName("meta")] | ||
public IDictionary<string, object> Meta { get; set; } = null!; | ||
|
||
[JsonPropertyName("jsonapi")] | ||
public JsonapiObject Jsonapi { get; set; } = null!; | ||
|
||
[Required] | ||
[JsonPropertyName("links")] | ||
public LinksInResourceDocument Links { get; set; } = null!; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/JsonApiDotNetCore.OpenApi/JsonApiObjects/JsonapiObject.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
using System.Text.Json.Serialization; | ||
using JetBrains.Annotations; | ||
|
||
namespace JsonApiDotNetCore.OpenApi.JsonApiObjects; | ||
|
||
[UsedImplicitly(ImplicitUseTargetFlags.Members)] | ||
internal sealed class JsonapiObject | ||
{ | ||
[JsonPropertyName("version")] | ||
public string Version { get; set; } = null!; | ||
|
||
[JsonPropertyName("ext")] | ||
public ICollection<string> Ext { get; set; } = null!; | ||
|
||
[JsonPropertyName("profile")] | ||
public ICollection<string> Profile { get; set; } = null!; | ||
|
||
[JsonPropertyName("meta")] | ||
public IDictionary<string, object> Meta { get; set; } = null!; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.