Skip to content

Cannot generate schema if property and class have same name #248

Closed
@johan-lindqvist

Description

@johan-lindqvist

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions