azure-functions-openapi-extension icon indicating copy to clipboard operation
azure-functions-openapi-extension copied to clipboard

Cannot generate schema if property and class have same name

Open johan-lindqvist opened this issue 4 years ago • 0 comments

Describe the issue

public class SomeDto
{
  public IEnumerable<OtherClass> OtherClass { get; set; }
}

public class OtherClass
{
  public string X { get; set; }

  public double Y { get; set; }
}

Results in the following error:

Could not resolve reference: Could not resolve pointer: /components/schemas/otherClass does not exist in document

If I rename the OtherClass class to OtherClassDto or if I change the property name for OtherClass in SomeDto it manages fine, so there seems to be an issue where it doesn't handle if the property name and the class name is the same when using IEnumerable. I saw that you fixed something related to this in #247 and I tried importing the project to my solution but was unable to do so, so this might be solved in 0.9.

Any of these examples work:

public class SomeDto
{
  public IEnumerable<OtherClass> OtherClassDto { get; set; }
}
public class SomeDto
{
  public IEnumerable<OtherClassDto> OtherClass { get; set; }
}

To Reproduce See above

Expected behavior I expect to be able to give a class and a property the same name without it failing to generate the schema.

Environment (please complete the following information, if applicable):

  • OS: Windows
  • Browser: Chrome
  • Version: 94

johan-lindqvist avatar Sep 30 '21 11:09 johan-lindqvist