3

I'm working on a swagger API, and have two classes with the same name but different namespaces - foo.Profile and bar.Profile.

The schema ends up looking like this (trimmed to just the important parts). Notice that both endpoints say they return #/definitions/Profile, but that definition is for foo.Profile. A definition for bar.Profile doesn't exist

{
    "paths":{
        "/v1/project-data/profiles":{
            "get":{
                "responses":{
                    "200":{
                        "schema":{
                            "$ref":"#/definitions/Profile"
                        }
                    }
                }
            }
        },
        "/v1/apc/profiles":{
            "get":{
                "responses":{
                    "200":{
                        "schema":{
                            "$ref":"#/definitions/Profile"
                        }
                    }
                }
            }
        }
    },
    "definitions":{
        "Profile":{
            "description":"Java type: foo.Profile",
            "properties":{
                ...
            }
        },
    }
}

Is there a way to make swagger carry separate definitions for these two classes, so the response schema can be properly conveyed to the users?

Changing the class names to be distinct is possible, but isn't desirable. They're already namespaced into logical groups, so calling them something other than Profile would just be awkward.

I'm using these versions, and can't change them as this has to integrate into a larger project:

  • Java 1.8
  • Restlet 2.3.5
  • Swagger Wordnik 1.5.3
Steve
  • 534
  • 1
  • 4
  • 13
  • 3
    Does this answer your question? [Swagger different classes in different namespaces with same name don't work](https://stackoverflow.com/questions/56475384/swagger-different-classes-in-different-namespaces-with-same-name-dont-work) –  Feb 06 '20 at 11:06

0 Answers0