NSwag does not generate OpenAPI descriptions from code comments for referenced assemblies

66 Views Asked by At

I have a .Net API project from which I reference a .Net DataAccess project.

I am using NSwag to generate OpenAPI, which generates a swagger.json file with the OpenAPI documentation.

It works well, however it doesnt generate OpenAPI descriptions for the classes and their properties defined in the DataAcces project.

The DataAccess project is from Nuget and the package contains the assembly .dll along with a .xml documentation file.

Does anyone know how to force NSwag to generate OpenAPI descriptions for the types in this assembly?

Content of swagger.json for a class defined in API project:

"ApiClass": {
    "type": "object",
    "description": "Hello!", // Generated from comments
    "additionalProperties": false,
    "properties": {
      "property1": {
        "type": "string",
        "description": "Hello back!", // Generated from comments
        "nullable": true
      },

Content of swagger.json for a class defined in the DataAccess project. There are no desciptions generated.

    "DataAccessClass": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "property1": {
            "type": "integer",
            "format": "int32"
          },
          "property2": {
            "type": "string",
            "nullable": true
          },

I dont really how NSwag generates the swagger.json file. I am guessing it uses XML documentation files? Those are being generated properly and as I mentioned when I download the DataAccess project from Nugget it downloads the .dll and also the XML documentation file.

Lest assume the class "DataAccessClass"... The DataAccesses XML documentation file does contain the definition of it, the APIs xml doesnt. The swagger.json however contains the definition of it, so I am guessing the NSwag doesnt solely relies on xml documentation of APIs project, but I dont know how to achieve for it to also generate the descriptions.

I tried playing with ResolveExternalXmlDocumentation setting In Startup.cs when adding OpenAPI document, but that doesnt seem to do anything.

0

There are 0 best solutions below