Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Individual declarations in merged declaration 'Duration' must be all exported or all local.ts(2395) #12102


User avatar
0
kalidarscope created

19 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @kalidarscope

    I couldn't see the code block in the screenshot. Could you share a new screenshot with a higher resolution ? Please also share how this problem happens.

  • User Avatar
    0
    kalidarscope created

    Could you please help me to this issue?

  • User Avatar
    0
    kalidarscope created

    any update on this issue?

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @kalidarscope,

    What is your project version? I checked the project's latest version and did not encounter such an error.

  • User Avatar
    0
    kalidarscope created

    project version 13.2.0

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @kalidarscope,

    I can reproduce this in my project. Could you share your project with us? [email protected]

  • User Avatar
    0
    kalidarscope created

    Hi m.aliozkaya, This is product we cant share and can we schedule call?

  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi kalidarscope

    By default, we don't use the Duration class in service-proxies.ts. You can remove it from here, or it seems that you have a class with the same name in a different module or in service-proxies.ts. You could consider renaming it to avoid the conflict.

  • User Avatar
    0
    kalidarscope created

    Yes, we removed it from service-proxies.ts, but it gets automatically regenerated when we run refresh.bat.

  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi kalidarscope

    Can you share with us the details of the Duration class created in other service-proxies.ts, not the Duration class imported by 'luxon'? Thank you.

  • User Avatar
    0
    kalidarscope created

    Below class was generated in service-proxies.ts

    export class Duration implements IDuration { negative!: boolean; years!: number; months!: number; days!: number; hours!: number; minutes!: number; seconds!: number;

    constructor(data?: IDuration) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }
    
    init(_data?: any) {
        if (_data) {
            this.negative = _data["negative"];
            this.years = _data["years"];
            this.months = _data["months"];
            this.days = _data["days"];
            this.hours = _data["hours"];
            this.minutes = _data["minutes"];
            this.seconds = _data["seconds"];
        }
    }
    
    static fromJS(data: any): Duration {
        data = typeof data === 'object' ? data : {};
        let result = new Duration();
        result.init(data);
        return result;
    }
    
    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["negative"] = this.negative;
        data["years"] = this.years;
        data["months"] = this.months;
        data["days"] = this.days;
        data["hours"] = this.hours;
        data["minutes"] = this.minutes;
        data["seconds"] = this.seconds;
        return data;
    }
    

    }

    export interface IDuration { negative: boolean; years: number; months: number; days: number; hours: number; minutes: number; seconds: number; }

    How is the above Duration class generated? Because of this class, the import import { DateTime, Duration } from "luxon"; is causing an error.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @kalidarscope

    There must be a class named Duration defined on the server side. Could you search your project and see if it exists ?

  • User Avatar
    0
    kalidarscope created

    Yes, I searched my project, but that class does not exist.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Can you use it in your code ? It might be coming from a library you are using.

  • User Avatar
    0
    kalidarscope created

    I did not use any of my code, so from which library is this class coming?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can try the solution below;

    1. First define a document filter like this
    public class MyCustomDocFilter : IDocumentFilter
    {
    	public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
    	{
    		swaggerDoc.Components.Schemas.Remove("Duration");
    	}
    }
    
    1. Then, use this in your Startup.cs as shown below;
    private void ConfigureSwagger(IServiceCollection services)
    {
    	services.AddSwaggerGen(options =>
    	{
    		......
    		options.DocumentFilter<MyCustomDocFilter>();
    		.....
    	});
    }
    
  • User Avatar
    0
    kalidarscope created

    After adding the above code, I tried to run refresh.bat, but I am getting the following error.

  • User Avatar
    0
    kalidarscope created

    any update on this?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @kalidarscope

    Could you send an email to [email protected] about this ? We will help you.

    Thanks,