Giter VIP home page Giter VIP logo

crud-gen's Introduction

REST API to CRUD App Generator

This project aims to automate the generation of basic CRUD (Create, Read, Update, Delete) applications directly from REST API specifications (OpenAPI / Swagger).

Features

  • API Analysis: Parse OpenAPI specs to extract endpoints, data models, and potential relationships.
  • TypeScript Model Generation: Generate TypeScript interfaces representing API resources for type safety in the frontend.
  • UI Scaffolding: Create basic React and/or Vue components (forms, lists, detail views) wired to the API.
  • Customization (Planned): Allow users to adjust generated UI and model behavior.

Getting Started

  1. Install dependencies: npm install
  2. Provide an OpenAPI spec: (Place your spec file in the project)
  3. Run the generator: #(add the command to run your tool once developed)

Contributing

We welcome contributions to improve this project! Please refer to the unit tests in [issue #1](link to the issue) for guidance on core functionality.

  1. Fork the repository.
  2. Create a feature branch.
  3. Implement changes and accompanying tests.
  4. Submit a pull request.

crud-gen's People

Contributors

bluebull7 avatar

Watchers

 avatar

crud-gen's Issues

CRUD App Generator: API Analysis and Model Generation Unit Tests

Overview

This issue outlines the essential unit tests to ensure the robustness and accuracy of our CRUD app generator's API analysis engine and TypeScript model generation capabilities. The success of these components is crucial for creating reliable and type-safe frontend applications based on REST APIs.

Unit Tests

Basic Parsing

  • Scenario: Correct extraction of endpoints and operations from a valid OpenAPI spec.
  • Description: The API analysis engine can process an OpenAPI spec, identifying all defined endpoints, their corresponding HTTP methods, and any operation IDs.
  • Acceptance Criteria:
    • Test asserts equality between extracted endpoints and methods with expected values.

Data Type Mapping

  • Scenario: Accurate translation of OpenAPI data types to TypeScript.
  • Description: The model generator correctly maps the following from OpenAPI to TypeScript:
    • Primitive types (string, number, boolean, date, etc.), including format variations.
    • Enums (conversion to suitable TypeScript representations).
  • Acceptance Criteria:
    • Tests assert that generated TypeScript interfaces/types accurately reflect the OpenAPI schema structure.

Relationship Inference (If applicable)

  • Scenario: Detection of implied relationships between API resources.
  • Description: If supported, the tool analyzes API endpoints and response structures to infer potential relationships between entities. These relationships are reflected in the generated TypeScript models.
  • Acceptance Criteria:
    • Tests assert that generated TypeScript models include properties or interfaces that represent the inferred relationships.

React/Vue Scaffolding (Basic Data Display)

  • Scenario: Generated components interact with the API.
  • Description: Ensure that generated React (or Vue) components can:
    • Fetch data from the API using the correct HTTP methods.
    • Map API responses to the generated TypeScript models.
    • Display the fetched data in user-friendly UI elements.
  • Acceptance Criteria:
    • Tests (using a mocking approach) assert that UI components render data as expected based on mock API responses.

Additional Considerations

  • Error Handling: Tests should cover how the tool handles invalid OpenAPI specs and unexpected data structures.
  • Complexity: Start with a simple API spec and gradually increase complexity to test various scenarios thoroughly.

Acceptance Criteria (Overall)

  • Each unit test scenario has clearly defined success/failure conditions.
  • Unit tests are implemented using a suitable testing framework (e.g., Jest).
  • Unit tests provide sufficient coverage for the core functionality of the API analysis engine and model generator.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.