-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SuperHeadersProcessor to OpenApi (#117)
Introduced the `SuperHeadersProcessor` class to manage required client and developer contact headers for API requests. fixes #116
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
42 changes: 42 additions & 0 deletions
42
src/Helldivers-2-API/OpenApi/OperationProcessors/SuperHeadersProcessor.cs
This file contains 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,42 @@ | ||
using NSwag; | ||
using NSwag.Generation.Processors; | ||
using NSwag.Generation.Processors.Contexts; | ||
|
||
namespace Helldivers.API.OpenApi.OperationProcessors; | ||
|
||
/// <summary> | ||
/// The <see cref="SuperHeadersProcessor"/> is used to add headers that are required for the API to identify | ||
/// the client and to provide developer contact information. | ||
/// </summary> | ||
public class SuperHeadersProcessor : IOperationProcessor | ||
{ | ||
/// <inheritdoc /> | ||
public bool Process(OperationProcessorContext context) | ||
{ | ||
context.OperationDescription.Operation.Parameters.Add( | ||
new OpenApiParameter | ||
{ | ||
Name = Constants.CLIENT_HEADER_NAME, | ||
Kind = OpenApiParameterKind.Header, | ||
Type = NJsonSchema.JsonObjectType.String, | ||
IsRequired = true, | ||
Description = "The name of the header that identifies the client to the API.", | ||
Default = string.Empty | ||
} | ||
); | ||
|
||
context.OperationDescription.Operation.Parameters.Add( | ||
new OpenApiParameter | ||
{ | ||
Name = Constants.CONTACT_HEADER_NAME, | ||
Kind = OpenApiParameterKind.Header, | ||
Type = NJsonSchema.JsonObjectType.String, | ||
IsRequired = true, | ||
Description = "The name of the header with developer contact information.", | ||
Default = string.Empty | ||
} | ||
); | ||
|
||
return true; | ||
} | ||
} |
This file contains 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