Skip to content

[REQ] Automated Code Generation for Inter-Parameter Dependencies in Web APIs #20462

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

Open
saman-barakat opened this issue Jan 14, 2025 · 0 comments

Comments

@saman-barakat
Copy link

Description

The current tools for generating code templates from web API specifications neglect the inter-parameter dependencies—relationships between input parameters that are common in practice but often described in natural language [1]. Developers are left to implement validation logic for these dependencies manually, which is error-prone and time-consuming.

In my PhD work, I introduced IDLGen, an extension of the OpenAPI Generator ecosystem, aimed at automating the generation of validation code for inter-parameter dependencies in web APIs. This work was presented at the International Conference on Service-Oriented Computing (ICSOC) 2023 [2]. IDLGen leverages the IDL4OAS extension [3] to specify these dependencies within OpenAPI Specification (OAS) files and generates Java and Python code to manage them.

Evaluation results show the effectiveness of the tool, generating up to 9.4 times more lines of Java code than the existing generator. This leads to average time savings ranging from 16 to 24 minutes when implementing API operations, including between one and three dependencies when compared to manual coding. More importantly, the generated code reduces human errors, significantly improving the reliability of web APIs.

Problem

  • Lack of automated handling of inter-parameter dependencies in existing tools, requiring developers to manually code the validation logic for dependencies.
  • Error-prone manual implementation, leading to possible mistakes in API operations.

Proposed Solution

IDLGen extension for the OpenAPI Generator tool ecosystem to automate the generation of Java and Python code for handling inter-parameter dependencies in web APIs [4].

Expected Benefits

  • Significant time savings (16 to 24 minutes) when handling inter-parameter dependencies.
  • Reduction of human errors in API operations, enhancing reliability.
  • Greater efficiency in API development, with up to 9.4 times more lines of generated code than current solutions.

Steps to Reproduce

  1. Use the IDL4OAS extension to specify inter-parameter dependencies in OpenAPI Specification files.
  2. Use the IDLGen extension to generate Java or Python code from the OAS file.
  3. Observe the generated code for validation logic related to inter-parameter dependencies.

Additional Context

This extension significantly improves the development of web APIs that require the management of inter-parameter dependencies, ensuring reliable and efficient code generation. More information can be found on the project website.

Examples

The following screenshot displays the Java code automatically generated by IDLGen to manage inter-parameter dependencies in a web API.

IDLGenExample

References

[1] A. Martin-Lopez, S. Segura, and A. Ruiz-Cortés, "A catalogue of inter-parameter dependencies in RESTful web APIs," in Service-Oriented Computing, S. Yangui, I. Bouassida Rodriguez, K. Drira, and Z. Tari, Eds., Cham: Springer International Publishing, 2019, pp. 399–414, doi: 10.1007/978-3-030-33702-5_31.

[2] S. Barakat, A.B. Sánchez, and S. Segura, "IDLGen: Automated code generation for inter-parameter dependencies in web APIs," in Service-Oriented Computing, F. Monti, S. Rinderle-Ma, A. Ruiz Cortés, Z. Zheng, and M. Mecella, Eds., Cham: Springer International Publishing, 2023, pp. 128-141, doi: 10.1007/978-3-031-48421-6_11.

[3] A. Martin-Lopez, S. Segura, C. Müller and A. Ruiz-Cortés, "Specification and Automated Analysis of Inter-Parameter Dependencies in Web APIs," in IEEE Transactions on Services Computing, vol. 15, no. 4, pp. 2342-2355, 1 July-Aug. 2022, doi: 10.1109/TSC.2021.3050610.

[4] S. Barakat, A. B. Sánchez, and S. Segura. IDLGen. https://github.com/ssegura/
openapi-generator/tree/IDLGen-extension
, 2023. Accessed: July 2023.

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

No branches or pull requests

1 participant