Verbesserung Auth, Webhook-Handling & Codacy-Integration

- BasicAuthenticationAttribute: AllowAnonymous-Handling ergänzt, Fehlerbehandlung für ungültige Header verbessert, WWW-Authenticate-Header korrigiert, Credential-Handling robuster gestaltet.
- WiseController: Webhook akzeptiert jetzt JSON und Text, asynchrone Verarbeitung, robustere Deserialisierung, <AllowAnonymous> auf Klassenebene.
- WiseWebhookExampleProcessor: OpenAPI/Swagger-Doku erweitert (application/json & text/plain, Beispiele, flexiblere Schemas).
- SwaggerConfig: Unsichtbares Zeichen entfernt.
- .gitignore: Codacy-spezifische Anweisungen ausgeschlossen.
- codacy.instructions.md: Neue Datei mit KI-Verhaltensregeln für Codacy-Analysen hinzugefügt.
This commit is contained in:
2025-12-10 15:12:02 +01:00
parent a6cbf6ab56
commit 5c8daaabc0
6 changed files with 157 additions and 53 deletions

View File

@@ -1,22 +1,39 @@
Imports NSwag
Imports NSwag.Generation.Processors
Imports NSwag.Generation.Processors.Contexts
Imports NJsonSchema
Public Class WiseWebhookExampleProcessor
Implements IOperationProcessor
Public Class WiseWebhookExampleProcessor
Implements IOperationProcessor
Public Function Process(context As OperationProcessorContext) As Boolean Implements IOperationProcessor.Process
Public Function Process(context As OperationProcessorContext) As Boolean Implements IOperationProcessor.Process
If context.ControllerType.Name = "WiseController" AndAlso context.MethodInfo.Name = "Webhook" Then
Dim operation = context.OperationDescription.Operation
If operation.RequestBody IsNot Nothing AndAlso operation.RequestBody.Content.ContainsKey("application/json") Then
Dim content = operation.RequestBody.Content("application/json")
content.Example = New With {
If operation.RequestBody Is Nothing Then
operation.RequestBody = New OpenApiRequestBody()
operation.RequestBody.IsRequired = False
End If
If Not operation.RequestBody.Content.ContainsKey("application/json") Then
operation.RequestBody.Content("application/json") = New OpenApiMediaType() With {
.Schema = JsonSchema.CreateAnySchema()
}
End If
If Not operation.RequestBody.Content.ContainsKey("text/plain") Then
operation.RequestBody.Content("text/plain") = New OpenApiMediaType() With {
.Schema = JsonSchema.CreateAnySchema()
}
End If
Dim jsonContent = operation.RequestBody.Content("application/json")
jsonContent.Example = New With {
.event_type = "balance.credit",
.data = New With {
.id = 123456789,
.balance_id = 99887766,
.amount = New With {
.value = 1500.00,
.value = 1500.0,
.currency = "EUR"
},
.occurred_at = "2025-12-06T10:15:30Z",
@@ -24,8 +41,10 @@ Public Class WiseWebhookExampleProcessor
.sender_name = "ACME GmbH"
}
}
Dim textContent = operation.RequestBody.Content("text/plain")
textContent.Example = "hello world"
End If
End If
Return True
End Function
End Class
Return True
End Function
End Class