You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to generate the documentation through the Swagger CLI, but my application has a call to the AWS Secret Manager. Therefore, when I'm building the application, the Swagger ToFile returns an error when querying the AWS service. Is there a way to generate the document without necessarily running the application?
Done executing task "Exec".
Task "Exec"
Environment Variables passed to tool:
DOTNET_ROLL_FORWARD=LatestMajor
dotnet swagger tofile --output .\swagger.json ..\...\API.dll v1
Unhandled exception. System.AggregateException: One or more errors occurred. (The security token included in the request is expired)
---> Amazon.SecretsManager.AmazonSecretsManagerException: The security token included in the request is expired
---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
at Amazon.Runtime.HttpWebRequestMessage.ProcessHttpResponseMessage(HttpResponseMessage responseMessage)
at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)
at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
My Program.cs, I'm placing the call to the aws secret manager as an IConfigurationSource
WebApplicationBuilderbuilder= WebApplication.CreateBuilder(args);
builder.Host.AddSecretsManager("CampaignManagerSecrets"); <= Here
builder.Services
.AddInternalService(builder.Configuration);
Additional context
No response
The text was updated successfully, but these errors were encountered:
Is there a way to generate the document without necessarily running the application?
There is not - this is fundamentally how OpenAPI generation works. The application is run so that all your filters, versioning, etc. is applied to the document. Only reflection isn't sufficient.
You'll need to make your application "generator aware" so that it doesn't use/need the bits that won't work outside of your real deployed application when the OpenAPI document is generated.
Possible solutions:
Run with a specific environment name instead of Development/Production
Run with a specific environment variable defined that indicates the same (e.g. OPENAPI_GENERATOR=true)
Check the name of the entrypoint assembly to see if it's the generator
Then given which way you want to check for "is generator", conditionally not include SSM as a configuration source.
What are you wanting to achieve?
Hello guys,
I'm trying to generate the documentation through the Swagger CLI, but my application has a call to the AWS Secret Manager. Therefore, when I'm building the application, the Swagger ToFile returns an error when querying the AWS service. Is there a way to generate the document without necessarily running the application?
What code or approach do you have so far?
Project csproj
Output error:
My Program.cs, I'm placing the call to the aws secret manager as an IConfigurationSource
Additional context
No response
The text was updated successfully, but these errors were encountered: