Skip to content
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

Class and constructor variables are named after ref schema class #341

Open
mdanilakis opened this issue Oct 6, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@mdanilakis
Copy link

Describe the bug

Class and constructor variables are named after ref schema class name which does not compile. We are only using this template because of the handy artifactType param that can be set to library because we want the models only.

How to Reproduce

Define a schema with props referencing another schema e.g.:

components:
  schemas:
    MySchema:
      type: object
      properties:
        prop1:
          $ref: '#components/schemas/MyOtherSchema'
        prop2:
          $ref: '#components/schemas/MyOtherSchema'
    MyOtherSchema:
      type: object
      properties:
        value:
          type: number
        unit:
          type: string

Expected behavior

Expected behavior would be to generate a class MySchema with a constructor and member variables named after the prop names e.g.:

public class MySchema {
  
  private MyOtherSchema prop1;
  private MyOtherSchema prop2;  

  public MySchema(MyOtherSchema prop1, MyOtherSchema prop2) {
    this.prop1 = prop1;
    this.prop2 = prop2;
  }
}

Actual behavior

Does not compile (variables already defined):

public class MySchema {
  
  private MyOtherSchema myOtherSchema;
  private MyOtherSchema myOtherSchema;  

  public MySchema(MyOtherSchema myOtherSchema, MyOtherSchema myOtherSchema) {
    this.myOtherSchema = myOtherSchema;
    this.myOtherSchema = myOtherSchema;
  }
}
@mdanilakis mdanilakis added the bug Something isn't working label Oct 6, 2023
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant