Skip to content
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

Exception happens when trying to access swaggerui running in docker #314

Closed
vorrtas opened this issue Nov 2, 2022 · 1 comment
Closed
Labels
bug Something isn't working fixed the bug has been squashed

Comments

@vorrtas
Copy link

vorrtas commented Nov 2, 2022

I think i can't use swagger inside docker or maybe i'm doing something wrong

image

Context:
Dockerimage: mcr.microsoft.com/dotnet/aspnet:6.0.10-alpine3.16-amd64

Relevant swagger config:

services.AddSwaggerDoc(settings =>
        {
            settings.DocumentName = configuration.GetValue<string>("SWAGGER:DOCUMENT_NAME");
            settings.Title = configuration.GetValue<string>("SWAGGER:TITLE");
            settings.Version = configuration.GetValue<string>("SWAGGER:VERSION");
            settings.Description = configuration.GetValue<string>("SWAGGER:DESCRIPTION");
        }, shortSchemaNames: true);

...
        app.UseOpenApi();
        app.UseSwaggerUi3(s =>
            s.ConfigureDefaults()
        );

Error message:
System.TypeInitializationException: The type initializer for 'FastEndpoints.Swagger.OperationProcessor' threw an exception.
---> System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en-US is an invalid culture identifier.
at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
at FastEndpoints.Swagger.OperationProcessor..cctor()
--- End of inner exception stack trace ---
at FastEndpoints.Swagger.OperationProcessor.Process(OperationProcessorContext ctx)
at NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.RunOperationProcessors(OpenApiDocument document, ApiDescription apiDescription, Type controllerType, MethodInfo methodInfo, OpenApiOperationDescription operationDescription, List`1 allOperations, OpenApiDocumentGenerator swaggerGenerator, OpenApiSchemaResolver schemaResolver)

I think it is because

https://github.com/FastEndpoints/FastEndpoints/blob/main/Src/Swagger/OperationProcessor.cs#L19
I'm not sure if we could replace it by something like:

private static readonly TextInfo textInfo = CultureInfo.Invariant.TextInfo;
// or if we need a copy
private static readonly TextInfo textInfo = (TextInfo)CultureInfo.Invariant.TextInfo.Clone();

Maybe it would help but I'm not certain. It might be a breaking change I'm not fammiliar with nswag library.

@dj-nitehawk
Copy link
Member

fixed in v5.3.1.2-beta
thanks for reporting.

@dj-nitehawk dj-nitehawk added bug Something isn't working fixed the bug has been squashed labels Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed the bug has been squashed
Development

No branches or pull requests

2 participants