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

File path as input to the generator #1591

Closed
nilkanth987 opened this issue Oct 28, 2023 · 8 comments · Fixed by #1601
Closed

File path as input to the generator #1591

nilkanth987 opened this issue Oct 28, 2023 · 8 comments · Fixed by #1601
Labels
enhancement New feature or request released on @next

Comments

@nilkanth987
Copy link
Contributor

Reason/Context

I am implementing AsyncAPI for the project that has huge set of REST APIs and Socket Events. To make things modularised and easy to read I have divided a single documentation into multiple files. Here is a reference to the file structure

/docs
  - asyncapi.yml
  - servers.yml
  /components
      - component1.yml
      - component2.yml
 /schemas
      - schema1.yml
      - schema2.yml 

These files are internally referenced so the modules are easy to read and edit.

Now when I try to create models using @asyncapi/modelina it accepts only parsed input. Even if I import a file and parse it to proved to the generated it will mess up the references in the file

Description

  • What changes have to be introduced?
    Let the generateToFiles method of the generator accept the file path as input. And process and parse the file before supplying it to the Renderer.
  • Will this be a breaking change?
    Yes
  • How could it be implemented/designed?
    I propose a new method generateFromFile which will accept file as input and can output models to multiple files.
@nilkanth987 nilkanth987 added the enhancement New feature or request label Oct 28, 2023
@github-actions
Copy link
Contributor

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.

@jonaslagoni
Copy link
Member

I propose a new method generateFromFile which will accept file as input and can output models to multiple files.

Makes sense to me 👍

Want to contribute it @nilkanth987 ?

@nilkanth987
Copy link
Contributor Author

@jonaslagoni , Yes I want to contribute.

@jonaslagoni
Copy link
Member

jonaslagoni commented Oct 30, 2023

Awesome! Let me know if you need any help 😄

@jonaslagoni
Copy link
Member

Hmm, yea might not be as easy to implement as first thought 😄 Cause we need to try and preserve the current architecture with processors and generators.

One generator preferably should not know about the input (how to handle it) but just give it to the processor.

Dilemma is, right now processors are interpreting the input entirely on their own, which makes it hard to know if its an url for an AsyncAPI document, or JSON Schema for example.

I think the best cause of action is to add a input processor type called inputType with each input processor as value, that forces the input processor to process the input.

Then the input in these cases are just an url, thats it. Now you should be able to pass generator.generate(url, {processors:{inputType: 'asyncapi'}})

That way all generators already understand this new input and all you have to change is 2 files.

Does that make sense @nilkanth987 ?

@nilkanth987
Copy link
Contributor Author

@jonaslagoni , Yes. Thanks for the guidance. I will implement it and let you know if I face any issues.

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 3.0.0-next.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 4.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants