loopback-connector-swagger icon indicating copy to clipboard operation
loopback-connector-swagger copied to clipboard

An item with the same key has already been added.

Open Jeegen opened this issue 6 years ago • 2 comments

I'm Using same in C# ODataWebAPI

public static void GenerateOpenApiDescription()
{
    IEdmModel model = GetEdmModel();
    OpenApiDocument document = model.ConvertToOpenApi();
    var outputJSON = document.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
    var outputYAML = document.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
}

public static IEdmModel GetEdmModel()
{
    // load EDM model here...
}

From this link https://github.com/microsoft/OpenAPI.NET.OData but when i run its seens error like An item with the same key has already been added. how to resolve this.

This is function where i call GetEdmModel()

public static void Register(HttpConfiguration config)
        {
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute
            (
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            config.MapODataServiceRoute("odata", "odata", GetEdmModel());

            IEdmModel model = GetEdmModel();
            OpenApiDocument doc = model.ConvertToOpenApi();
            var JSON = doc.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
            var YAML = doc.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
        }

Jeegen avatar Feb 25 '20 07:02 Jeegen

@Jeegen, I am trying to understand your question.

Can you please clarify what you are doing?

Also, please provide a minimal LB3 app that demonstrates your issue, and we can try to understand and debug. thx.

emonddr avatar Mar 13 '20 18:03 emonddr

@Jeegen, Closing due to inactivity. If you are still running into problems, feel free to leave a comment and I will reopen the issue.

emonddr avatar Mar 23 '20 19:03 emonddr