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

Api endpoint generator #494

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Api endpoint generator #494

wants to merge 24 commits into from

Conversation

shivahari
Copy link
Collaborator

Added API Auto Generation capability to the framework. This new change will help generate *_endpoint.py modules from an OpenAPI v3.0 spec. This partially automates creating API Automation test.

Run python api_auto_generator/endpoint_module_generator.py --help to get Help on how to run the generator script.

Changes include:

  • Adding a directory - api_auto_generator to house:
  1. API Auto generator scripts
  2. A Jinja2 template
  • Added a generic method - make_request to make HTTP requests
  • Updated requirements.txt file to add required modules

…resent or the endpoints have /api common base point
…le generated by the endpoint generator script
…er object to accommodate the generated Endpoint file
@shivahari shivahari requested a review from avinash010 October 30, 2024 16:34
Copy link
Collaborator

@avinash010 avinash010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shivahari While validating the open api spec for ACC model, I saw the script stopped parsing after it hit the error. Probably we can show an error for the failed endpoint and continue parsing for the next endpoint

- The json/data params to be passed to the requests method is generated from the request body
- A Python dictionary collecting all these values is generated
- Tge generated Python dictionary is redered on a Jinja2 template

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo in "The"

@@ -0,0 +1,100 @@
"""
What does this module do?:
- It creates an Endpoint file with a class from the OpenAPI spec
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need ":" here?

class NameGenerator():
"Base class for generating names"

def __init__(self,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have 2 lines after class definition to keep it consistent


# pylint: disable=too-many-branches, too-complex
def parse_request_body(self, request_body: specification.RequestBody) -> tuple[str, list, str]:
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shivahari : The codacy check is failing due to this pylint issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants