Black Friday Sale!
Save up to 50% off any plans! Valid from 23 Nov to 30 Nov - Also valid for the existing customers
Open Closed

Swagger Help for Duplicate Classes #5852

mdframe created

I know this is not a Swagger help forum but I was wondering if anyone has a solution for ANZ creating mulitple interfaces for the same table? I have a static code table to hold things such as status, grade and condition and different inventory and warehouse screens use this table. The RAD tool creates the same CodeLookupTableDto interface for each which then confuses Swagger. Is there an attribute or other marking mechanicsm to overcome this situation? Any ideas/examples are greatly appreciated.


4 Answer(s)
  • 0
    mdframe created

    So after some more digging into the Swagger documentation I found you can generate custom schema id's. I changed the Startup.cs code to add options.CustomSchemaIds(x => x.FullName) which results in the following for Swagger:

    ` //Swagger - Enable this line and the related lines in Configure method to enable swagger UI services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Info { Title = "SKUHive API", Version = "v1" }); options.DocInclusionPredicate((docName, description) => true);

                //Note: This is just for showing Authorize button on the UI. 
                //Authorize button's behaviour is handled in wwwroot/swagger/ui/index.html
                options.AddSecurityDefinition("Bearer", new BasicAuthScheme());
                options.CustomSchemaIds(x => x.FullName);

    The interface generated without issue. I will test to see if this causes any issues.

    I am all ears if a better way is recommended with ANZ.


  • 0
    mdframe created

    Thats not the answer! Everything was fine with refresh.bat however npm start results in hundreds of errors in service-proxies.ts ... more research.

  • 0
    ismcagdas created
    Support Team

    Hi @mdframe

    Have you solved this problem ?


  • 0
    tbentley created

    I don't know whether this solve it for mdframe but I changed the options.CustomSchemaIds(x => x. FullName) which resolved the issue with not being able to run the server code but, after doing an nswag refresh I am getting dozens of compilation errors when doing an npm start.