add user-id header field to swagger
This commit is contained in:
		
							parent
							
								
									6471d25244
								
							
						
					
					
						commit
						6c544eb523
					
				| @ -57,6 +57,7 @@ public class Startup | ||||
|             }); | ||||
| 
 | ||||
|             options.OperationFilter<AuthorizeCheckOperationFilter>(); | ||||
|             options.OperationFilter<AddUserIdHeaderFilter>(); | ||||
|         }); | ||||
| 
 | ||||
|         ConfigureAuthService(services); | ||||
| @ -291,4 +292,20 @@ public class Startup | ||||
|         eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>(); | ||||
|         eventBus.Subscribe<OrderStartedIntegrationEvent, OrderStartedIntegrationEventHandler>(); | ||||
|     } | ||||
|      | ||||
|     // HACK: no auth | ||||
|     private class AddUserIdHeaderFilter : IOperationFilter | ||||
|     { | ||||
|         public void Apply(OpenApiOperation operation, OperationFilterContext context) | ||||
|         { | ||||
|             operation.Parameters ??= new List<OpenApiParameter>(); | ||||
|              | ||||
|             operation.Parameters.Add(new OpenApiParameter | ||||
|             { | ||||
|                 Name = "user-id", | ||||
|                 In = ParameterLocation.Header, | ||||
|                 Required = false | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -242,6 +242,7 @@ static class CustomExtensionsMethods | ||||
|             }); | ||||
| 
 | ||||
|             options.OperationFilter<AuthorizeCheckOperationFilter>(); | ||||
|             options.OperationFilter<AddUserIdHeaderFilter>(); | ||||
|         }); | ||||
| 
 | ||||
|         return services; | ||||
| @ -400,4 +401,20 @@ static class CustomExtensionsMethods | ||||
|         }); | ||||
|         return services; | ||||
|     } | ||||
|      | ||||
|     // HACK: no auth | ||||
|     private class AddUserIdHeaderFilter : IOperationFilter | ||||
|     { | ||||
|         public void Apply(OpenApiOperation operation, OperationFilterContext context) | ||||
|         { | ||||
|             operation.Parameters ??= new List<OpenApiParameter>(); | ||||
|              | ||||
|             operation.Parameters.Add(new OpenApiParameter | ||||
|             { | ||||
|                 Name = "user-id", | ||||
|                 In = ParameterLocation.Header, | ||||
|                 Required = false | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user