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

ControllerBase is also generated #1535

Closed
roscoedeemarutam opened this issue Aug 14, 2018 · 14 comments
Closed

ControllerBase is also generated #1535

roscoedeemarutam opened this issue Aug 14, 2018 · 14 comments

Comments

@roscoedeemarutam
Copy link

hi,

I'm new to NSwag so please forgive my ignorance.
When I try to generate my basic scaffolded WebApi core project in visual studio, nswagstudio also generates the complete ControllerBase class, together with the ValuesController, which of course is not needed for an angular Api service (I expect only the ValuesController to be generated).. Can someone advise what i have to do so the generated swagger only contains my api classes and not the base class it inherits from, is this a setting in the nswag studio? Or am i not understanding something more fundamental here?

thx.
R

@roscoedeemarutam
Copy link
Author

small follow up. So, when i run my webapi core in the browser and go to the swagger page it does have to right swagger.json and when i use that one to generate my api service everything looks fine. So it goes wrong somewhere in the generation of the json trough the .net assembly. this is the json it generates from the assembly... it doesn't even have the values api?

{ "openapi": "3.0.0", "info": { "title": "", "version": "" }, "components": { "schemas": { "ValuesController": { "type": "object", "additionalProperties": false, "allOf": [ { "$ref": "#/components/schemas/ControllerBase" } ] }, "ControllerBase": { "type": "object", "x-abstract": true, "additionalProperties": false, "properties": { "httpContext": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/HttpContext" } ] }, "request": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/HttpRequest" } ] }, "response": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/HttpResponse" } ] }, "routeData": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/RouteData" } ] }, "modelState": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ModelStateDictionary" } ] }, "controllerContext": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ControllerContext" } ] }, "metadataProvider": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/IModelMetadataProvider" } ] }, "modelBinderFactory": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/IModelBinderFactory" } ] }, "url": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/IUrlHelper" } ] }, "objectValidator": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/IObjectModelValidator" } ] }, "user": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ClaimsPrincipal" } ] } } }, "HttpContext": { "type": "object", "x-abstract": true, "additionalProperties": false }, "HttpRequest": { "type": "object", "x-abstract": true, "additionalProperties": false }, "HttpResponse": { "type": "object", "x-abstract": true, "additionalProperties": false }, "RouteData": { "type": "object", "additionalProperties": false, "properties": { "dataTokens": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/RouteValueDictionary" } ] }, "routers": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/IRouter" } }, "values": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/RouteValueDictionary" } ] } } }, "RouteValueDictionary": { "type": "object", "additionalProperties": false, "properties": { "item": { "oneOf": [ {}, { "type": "null" } ] }, "comparer": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/IEqualityComparerOfString" } ] }, "count": { "type": "integer", "format": "int32" }, "keys": { "type": [ "array", "null" ], "items": { "type": "string" } }, "values": { "type": [ "array", "null" ], "items": {} } } }, "IEqualityComparerOfString": { "type": "object", "x-abstract": true, "additionalProperties": false }, "IRouter": { "type": "object", "x-abstract": true, "additionalProperties": false }, "ModelStateDictionary": { "type": "object", "additionalProperties": false, "properties": { "root": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ModelStateEntry" } ] }, "maxAllowedErrors": { "type": "integer", "format": "int32" }, "hasReachedMaxErrors": { "type": "boolean" }, "errorCount": { "type": "integer", "format": "int32" }, "count": { "type": "integer", "format": "int32" }, "keys": { "type": "array", "items": { "type": "string" } }, "values": { "type": "array", "items": { "$ref": "#/components/schemas/ModelStateEntry" } }, "isValid": { "type": "boolean" }, "validationState": { "$ref": "#/components/schemas/ModelValidationState" }, "item": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ModelStateEntry" } ] } } }, "ModelStateEntry": { "type": "object", "x-abstract": true, "additionalProperties": false, "properties": { "rawValue": { "oneOf": [ {}, { "type": "null" } ] }, "attemptedValue": { "type": [ "null", "string" ] }, "errors": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ModelErrorCollection" } ] }, "validationState": { "$ref": "#/components/schemas/ModelValidationState" } } }, "ModelErrorCollection": { "type": "object", "additionalProperties": false, "allOf": [ { "type": "array", "items": { "$ref": "#/components/schemas/ModelError" } } ] }, "ModelError": { "type": "object", "additionalProperties": false, "properties": { "exception": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/Exception" } ] }, "errorMessage": { "type": [ "null", "string" ] } } }, "Exception": { "type": "object", "additionalProperties": false, "properties": { "message": { "type": [ "null", "string" ] }, "innerException": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/Exception" } ] }, "stackTrace": { "type": [ "null", "string" ] }, "source": { "type": [ "null", "string" ] } } }, "ModelValidationState": { "type": "integer", "description": "", "x-enumNames": [ "Unvalidated", "Invalid", "Valid", "Skipped" ], "enum": [ 0, 1, 2, 3 ] }, "ControllerContext": { "type": "object", "additionalProperties": false, "properties": { "actionDescriptor": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ControllerActionDescriptor" } ] }, "valueProviderFactories": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/IValueProviderFactory" } } }, "allOf": [ { "$ref": "#/components/schemas/ActionContext" } ] }, "ControllerActionDescriptor": { "type": "object", "additionalProperties": false, "properties": { "controllerName": { "type": [ "null", "string" ] }, "actionName": { "type": [ "null", "string" ] }, "methodInfo": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/MethodInfo" } ] }, "controllerTypeInfo": { "type": [ "null", "string" ] }, "displayName": { "type": [ "null", "string" ] } }, "allOf": [ { "$ref": "#/components/schemas/ActionDescriptor" } ] }, "MethodInfo": { "type": "object", "x-abstract": true, "additionalProperties": false, "properties": { "memberType": { "$ref": "#/components/schemas/MemberTypes" }, "returnParameter": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ParameterInfo" } ] }, "returnType": { "type": [ "null", "string" ] } }, "allOf": [ { "$ref": "#/components/schemas/MethodBase" } ] }, "MemberTypes": { "type": "integer", "description": "", "x-enumFlags": true, "x-enumNames": [ "Constructor", "Event", "Field", "Method", "Property", "TypeInfo", "Custom", "NestedType", "All" ], "enum": [ 1, 2, 4, 8, 16, 32, 64, 128, 191 ] }, "ParameterInfo": { "type": "object", "additionalProperties": false, "properties": { "attributes": { "$ref": "#/components/schemas/ParameterAttributes" }, "member": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/MemberInfo" } ] }, "name": { "type": [ "null", "string" ] }, "parameterType": { "type": [ "null", "string" ] }, "position": { "type": "integer", "format": "int32" }, "isIn": { "type": "boolean" }, "isLcid": { "type": "boolean" }, "isOptional": { "type": "boolean" }, "isOut": { "type": "boolean" }, "isRetval": { "type": "boolean" }, "defaultValue": { "oneOf": [ {}, { "type": "null" } ] }, "rawDefaultValue": { "oneOf": [ {}, { "type": "null" } ] }, "hasDefaultValue": { "type": "boolean" }, "customAttributes": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/CustomAttributeData" } }, "metadataToken": { "type": "integer", "format": "int32" } } }, "ParameterAttributes": { "type": "integer", "description": "", "x-enumFlags": true, "x-enumNames": [ "None", "In", "Out", "Lcid", "Retval", "Optional", "HasDefault", "HasFieldMarshal", "Reserved3", "Reserved4", "ReservedMask" ], "enum": [ 0, 1, 2, 4, 8, 16, 4096, 8192, 16384, 32768, 61440 ] }, "MemberInfo": { "type": "object", "x-abstract": true, "additionalProperties": false, "properties": { "module": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/Module" } ] }, "customAttributes": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/CustomAttributeData" } }, "metadataToken": { "type": "integer", "format": "int32" } } }, "Module": { "type": "object", "x-abstract": true, "additionalProperties": false, "properties": { "assembly": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/Assembly" } ] }, "fullyQualifiedName": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "mdStreamVersion": { "type": "integer", "format": "int32" }, "moduleVersionId": { "type": "string", "format": "guid" }, "scopeName": { "type": [ "null", "string" ] }, "moduleHandle": { "$ref": "#/components/schemas/ModuleHandle" }, "customAttributes": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/CustomAttributeData" } }, "metadataToken": { "type": "integer", "format": "int32" } } }, "Assembly": { "type": "object", "x-abstract": true, "additionalProperties": false, "properties": { "definedTypes": { "type": [ "array", "null" ], "items": { "type": "string" } }, "exportedTypes": { "type": [ "array", "null" ], "items": { "type": "string" } }, "codeBase": { "type": [ "null", "string" ] }, "entryPoint": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/MethodInfo" } ] }, "fullName": { "type": [ "null", "string" ] }, "imageRuntimeVersion": { "type": [ "null", "string" ] }, "isDynamic": { "type": "boolean" }, "location": { "type": [ "null", "string" ] }, "reflectionOnly": { "type": "boolean" }, "isFullyTrusted": { "type": "boolean" }, "customAttributes": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/CustomAttributeData" } }, "escapedCodeBase": { "type": [ "null", "string" ] }, "manifestModule": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/Module" } ] }, "modules": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/Module" } }, "globalAssemblyCache": { "type": "boolean" }, "hostContext": { "type": "integer", "format": "int64" }, "securityRuleSet": { "$ref": "#/components/schemas/SecurityRuleSet" } } }, "CustomAttributeData": { "type": "object", "additionalProperties": false, "properties": { "attributeType": { "type": [ "null", "string" ] }, "constructor": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ConstructorInfo" } ] }, "constructorArguments": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/CustomAttributeTypedArgument" } }, "namedArguments": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/CustomAttributeNamedArgument" } } } }, "ConstructorInfo": { "type": "object", "x-abstract": true, "additionalProperties": false, "properties": { "memberType": { "$ref": "#/components/schemas/MemberTypes" } }, "allOf": [ { "$ref": "#/components/schemas/MethodBase" } ] }, "MethodBase": { "type": "object", "x-abstract": true, "additionalProperties": false, "properties": { "methodImplementationFlags": { "$ref": "#/components/schemas/MethodImplAttributes" }, "callingConvention": { "$ref": "#/components/schemas/CallingConventions" }, "isAbstract": { "type": "boolean" }, "isConstructor": { "type": "boolean" }, "isFinal": { "type": "boolean" }, "isHideBySig": { "type": "boolean" }, "isSpecialName": { "type": "boolean" }, "isStatic": { "type": "boolean" }, "isVirtual": { "type": "boolean" }, "isAssembly": { "type": "boolean" }, "isFamily": { "type": "boolean" }, "isFamilyAndAssembly": { "type": "boolean" }, "isFamilyOrAssembly": { "type": "boolean" }, "isPrivate": { "type": "boolean" }, "isPublic": { "type": "boolean" }, "isConstructedGenericMethod": { "type": "boolean" }, "isGenericMethod": { "type": "boolean" }, "isGenericMethodDefinition": { "type": "boolean" }, "containsGenericParameters": { "type": "boolean" }, "isSecurityCritical": { "type": "boolean" }, "isSecuritySafeCritical": { "type": "boolean" }, "isSecurityTransparent": { "type": "boolean" } }, "allOf": [ { "$ref": "#/components/schemas/MemberInfo" } ] }, "MethodImplAttributes": { "type": "integer", "description": "", "x-enumNames": [ "Managed", "IL", "Native", "OPTIL", "Runtime", "CodeTypeMask", "Unmanaged", "ManagedMask", "NoInlining", "ForwardRef", "Synchronized", "NoOptimization", "PreserveSig", "AggressiveInlining", "InternalCall", "MaxMethodImplVal" ], "enum": [ 0, 0, 1, 2, 3, 3, 4, 4, 8, 16, 32, 64, 128, 256, 4096, 65535 ] }, "CallingConventions": { "type": "integer", "description": "", "x-enumFlags": true, "x-enumNames": [ "Standard", "VarArgs", "Any", "HasThis", "ExplicitThis" ], "enum": [ 1, 2, 3, 32, 64 ] }, "CustomAttributeTypedArgument": { "type": "object", "additionalProperties": false, "properties": { "argumentType": { "type": [ "null", "string" ] }, "value": { "oneOf": [ {}, { "type": "null" } ] } } }, "CustomAttributeNamedArgument": { "type": "object", "additionalProperties": false, "properties": { "memberInfo": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/MemberInfo" } ] }, "typedValue": { "$ref": "#/components/schemas/CustomAttributeTypedArgument" }, "memberName": { "type": [ "null", "string" ] }, "isField": { "type": "boolean" } } }, "SecurityRuleSet": { "type": "integer", "description": "", "x-enumNames": [ "None", "Level1", "Level2" ], "enum": [ 0, 1, 2 ] }, "ModuleHandle": { "type": "object", "additionalProperties": false, "properties": { "mdStreamVersion": { "type": "integer", "format": "int32" } } }, "ActionDescriptor": { "type": "object", "additionalProperties": false, "properties": { "id": { "type": [ "null", "string" ] }, "routeValues": { "type": [ "null", "object" ], "additionalProperties": { "type": "string" } }, "attributeRouteInfo": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/AttributeRouteInfo" } ] }, "actionConstraints": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/IActionConstraintMetadata" } }, "parameters": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/ParameterDescriptor" } }, "boundProperties": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/ParameterDescriptor" } }, "filterDescriptors": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/FilterDescriptor" } }, "displayName": { "type": [ "null", "string" ] }, "properties": { "type": [ "null", "object" ], "additionalProperties": {} } } }, "AttributeRouteInfo": { "type": "object", "additionalProperties": false, "properties": { "template": { "type": [ "null", "string" ] }, "order": { "type": "integer", "format": "int32" }, "name": { "type": [ "null", "string" ] }, "suppressLinkGeneration": { "type": "boolean" }, "suppressPathMatching": { "type": "boolean" } } }, "IActionConstraintMetadata": { "type": "object", "x-abstract": true, "additionalProperties": false }, "ParameterDescriptor": { "type": "object", "additionalProperties": false, "properties": { "name": { "type": [ "null", "string" ] }, "parameterType": { "type": [ "null", "string" ] }, "bindingInfo": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/BindingInfo" } ] } } }, "BindingInfo": { "type": "object", "additionalProperties": false, "properties": { "bindingSource": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/BindingSource" } ] }, "binderModelName": { "type": [ "null", "string" ] }, "binderType": { "type": [ "null", "string" ] }, "propertyFilterProvider": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/IPropertyFilterProvider" } ] }, "requestPredicate": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/FuncOfActionContextAndBoolean" } ] } } }, "BindingSource": { "type": "object", "additionalProperties": false, "properties": { "displayName": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "string" ] }, "isGreedy": { "type": "boolean" }, "isFromRequest": { "type": "boolean" } } }, "IPropertyFilterProvider": { "type": "object", "x-abstract": true, "additionalProperties": false }, "FuncOfActionContextAndBoolean": { "type": "object", "additionalProperties": false, "allOf": [ { "$ref": "#/components/schemas/MulticastDelegate" } ] }, "MulticastDelegate": { "type": "object", "x-abstract": true, "additionalProperties": false, "allOf": [ { "$ref": "#/components/schemas/Delegate" } ] }, "Delegate": { "type": "object", "x-abstract": true, "additionalProperties": false, "properties": { "method": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/MethodInfo" } ] }, "target": { "oneOf": [ {}, { "type": "null" } ] } } }, "FilterDescriptor": { "type": "object", "additionalProperties": false, "properties": { "filter": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/IFilterMetadata" } ] }, "order": { "type": "integer", "format": "int32" }, "scope": { "type": "integer", "format": "int32" } } }, "IFilterMetadata": { "type": "object", "x-abstract": true, "additionalProperties": false }, "IValueProviderFactory": { "type": "object", "x-abstract": true, "additionalProperties": false }, "ActionContext": { "type": "object", "additionalProperties": false, "properties": { "actionDescriptor": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ActionDescriptor" } ] }, "httpContext": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/HttpContext" } ] }, "modelState": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ModelStateDictionary" } ] }, "routeData": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/RouteData" } ] } } }, "IModelMetadataProvider": { "type": "object", "x-abstract": true, "additionalProperties": false }, "IModelBinderFactory": { "type": "object", "x-abstract": true, "additionalProperties": false }, "IUrlHelper": { "type": "object", "x-abstract": true, "additionalProperties": false }, "IObjectModelValidator": { "type": "object", "x-abstract": true, "additionalProperties": false }, "ClaimsPrincipal": { "type": "object", "additionalProperties": false, "properties": { "claims": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/Claim" } }, "identities": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/ClaimsIdentity" } }, "identity": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/IIdentity" } ] } } }, "Claim": { "type": "object", "additionalProperties": false, "properties": { "issuer": { "type": [ "null", "string" ] }, "originalIssuer": { "type": [ "null", "string" ] }, "properties": { "type": [ "null", "object" ], "additionalProperties": { "type": "string" } }, "subject": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ClaimsIdentity" } ] }, "type": { "type": [ "null", "string" ] }, "value": { "type": [ "null", "string" ] }, "valueType": { "type": [ "null", "string" ] } } }, "ClaimsIdentity": { "type": "object", "additionalProperties": false, "properties": { "authenticationType": { "type": [ "null", "string" ] }, "isAuthenticated": { "type": "boolean" }, "actor": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/ClaimsIdentity" } ] }, "bootstrapContext": { "oneOf": [ {}, { "type": "null" } ] }, "claims": { "type": [ "array", "null" ], "items": { "$ref": "#/components/schemas/Claim" } }, "label": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "nameClaimType": { "type": [ "null", "string" ] }, "roleClaimType": { "type": [ "null", "string" ] } } }, "IIdentity": { "type": "object", "x-abstract": true, "additionalProperties": false } } } }

@RicoSuter
Copy link
Owner

Can you share the nswag config file? Maybe you’re using the api explorer based generator as middleware and the reflection based one in cli?

@roscoedeemarutam
Copy link
Author

hi, thx for answering.

So, the only thing different from the instruction video (https://www.youtube.com/watch?v=lF9ZZ8p2Ciw&t=37s)

is my startup class (see blow) and the fact that I have to make the publish selfcontained because otherwise i get this error

"tem.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> System.IO.FileNotFoundException: Could not load the specified file.
File name: 'Microsoft.AspNetCore.Mvc.ViewFeatures'
Check if .NET Core is installed and 'dotnet' is globally available."

Startup Class

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddSwagger();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();
            app.UseSwaggerUi(typeof(Startup).GetTypeInfo().Assembly, settings =>
            {
                settings.GeneratorSettings.DefaultPropertyNameHandling =
                    PropertyNameHandling.CamelCase;
            });
        }
    }

.nswag configuration.

{
  "runtime": "NetCore21",
  "defaultVariables": null,
  "swaggerGenerator": {
    "typesToSwagger": {
      "classNames": [
        "MyWebApi.Controllers.ValuesController"
      ],
      "defaultPropertyNameHandling": "SnakeCase",
      "defaultReferenceTypeNullHandling": "Null",
      "defaultEnumHandling": "Integer",
      "flattenInheritanceHierarchy": false,
      "ignoreObsoleteProperties": false,
      "allowReferencesWithProperties": false,
      "generateKnownTypes": true,
      "generateXmlObjects": false,
      "output": "MyWebApi.Generated.json",
      "outputType": "Swagger2",
      "assemblyPaths": [
        "../MyWebApi/bin/Debug/netcoreapp2.1/MyWebApi.dll"
      ],
      "assemblyConfig": null,
      "referencePaths": [
        "C:/demoprojects/MyWebApi/MyWebApi/bin/Debug/netcoreapp2.1/publish/"
      ]
    }
  },
  "codeGenerators": {}
}

and then when i can generate the spec i get the nasty spec from my initial posts.

kind regards.
R

@RicoSuter
Copy link
Owner

You need to select "... via Reflection" (.NET Assembly only generates DTO schemas):

image

Or better use the new generators UseSwaggerUiWithApiExplorer(...) and "ASP.NET Core with API Explorer"

@RicoSuter
Copy link
Owner

@roscoedeemarutam
Copy link
Author

ok, super, looks like this is working!! thank you so much!

@roscoedeemarutam
Copy link
Author

Hi, one more small follow up question... So everything is working fine until I add references to the project then I get this error when generating the files... Any idea what i need to add (or remove)?

C:\Euromex.net\Euromex.ServiceHost\Euromex.ServiceHost.csproj(167,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.1.400\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
C:\Euromex.net\Euromex.Web\Euromex.Web.csproj(4337,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.1.400\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
System.InvalidOperationException: Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project.If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.

Kind regards,
R

@RicoSuter
Copy link
Owner

So this is with the new Api Explorer based generator?

@roscoedeemarutam
Copy link
Author

hi, yes, as long as i just use the application by itself its all going good and the moment I add a reference I get errors like this one?

@RicoSuter
Copy link
Owner

@roscoedeemarutam can you provide a sample project to repro this? I think you should create a new issue for this problem...

@roscoedeemarutam
Copy link
Author

ok! will do!

@roscoedeemarutam
Copy link
Author

ok, so... maybe not necessary anymore... It works when I put the nobuild checkbox in the project configuration!?

@RicoSuter
Copy link
Owner

Hmm if you run the generator as an msbuild task after the compilation, you should enable nobuild as the project is always built before the generator is running.

@roscoedeemarutam
Copy link
Author

yes, thats exaclty what we need to have a build task of the generator after compilation. So we'll go with the nobuild configuration. Anyway, thx again for the quick answers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants