asyncapi / modelina

A library for generating typed models based on inputs such as AsyncAPI, OpenAPI, and JSON Schema documents with high customization
https://modelina.org
Apache License 2.0
300 stars 175 forks source link

When schemas are in another file, they require additional fields. #1297

Open JFCote opened 1 year ago

JFCote commented 1 year ago

Describe the bug

It was suggested to me by a user in the Slack community to create a bug here: https://asyncapi.slack.com/archives/CQVJXFNQL/p1684436870155959

The problem is that when you separate the main spec from the schema, Modelina creates "anonymous" class by default. The solution is to add either $id or x-parser-schema-id to each schema and it will work as expected

How to Reproduce

Let's say we split our spec in 2 parts: Main: https://app.swaggerhub.com/apis/JEANFRANCOISCOTE/MainSpec/1.0.0 Models: https://app.swaggerhub.com/apis/JEANFRANCOISCOTE/SharedMessages/1.0.0

Create the models with Modelina in C# and notice the class will be named Anonymous_X

Expected behavior

Modelina should be able to find the name of the class since they are in the SharedMessages specification. We should not need to add a "vendor" field for this to be supported. Coming from an OpenAPI background and this is supported.

At least, there should be documentation about it how to get around this problem because putting the model in a shared place is a very common thing in AsyncAPI.

Thanks!

github-actions[bot] commented 1 year ago

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.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

AnimeshKumar923 commented 8 months ago

still valid? @jonaslagoni

jonaslagoni commented 8 months ago

Right now I dont have time to look into the underlying cause to make this a good first issue. If someone wants to dive into it please go ahead!

github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart: