Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
johan-lindqvist opened this issue Sep 30, 2021 · 2 comments
Closed

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

johan-lindqvist opened this issue Sep 30, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@johan-lindqvist
Copy link

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
@justinyoo
Copy link
Contributor

#610 takes care of this issue. The fix will be released in the next v2-preview release.

@CNBoland
Copy link

CNBoland commented Jan 9, 2025

Can we get this released along with other commits since previous release on 1/27/2023?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants