1

AWS Schema Registry (AWS EventBridge) requires OpenApi3 schema documents.

I have a dotnet assembly with types that are used for Detail of an AWS EventBridge message in an AWS Lambda Function assembly.

I would like to generate the OpenApi3 document for these types.

I have completed a spike where these types are return types of ASP.NET application and checked the swagger output. These desired types are present in the swagger output. But, these types do not live in the ASP.NET application, nor are they used in the ASP.NET core application. So, I know they can be generated into the schema.

I want to leave them in the AWS Lambda Function assembly but generate the schema into an OpenApiDocument. I have tried using nswag studio to examine the assembly, but since they are neither inputs or outputs of controller method (there are no controllers - it is an AWS Lambda assembly), they are not generating.

Any ideas on how I can generate the OpenApi3 schema document from types located in a library assembly like this?

Tim Bassett
  • 1,325
  • 1
  • 12
  • 23

1 Answers1

0

I'm using NSwagStudio version 13.2.3.0 and I have a .NET core class library which contains only types, no controllers or ASP.NET stuff whatsoever.

The steps I use in NSwagStudio to generate the OpenAPI specs are as follows:

  1. Set Runtime to the .NET version supported by the library (i.e. NetCore31). This is important, otherwise your assembly will not load properly.
  2. Select the .NET Assembly tab.
  3. Click the ... button next to .NET Assembly Paths and navigate to your assembly.
  4. Click the Load Assembly button. There should be no errors, and the Classes list should be populated with all the types in your assembly.
  5. By default no type is selected, so if you click Generate Outputs, the right-hand OpenAPI/Swagger Specification tab will be empty. So first check the types that you want to add to the OAS components/schemas and then click Generate Outputs.

Note: by default the spec model is Swagger 2.0, you need to select OpenApi3 under the Output Type drop-down below the list of classes loaded from the assembly.

Hope that helps.

M. F.
  • 1,654
  • 11
  • 16