This utility is designed to generate the necessary React files based on an OpenAPI specification, streamlining the creation of types, API methods, Redux slices, and sagas.
Before using this utility, ensure you have the following:
- Windows Operating System
- The OpenAPI (Swagger) specification file (
swagger.json
)
-
Download the Utility
Locate theapp
folder provided with this project. This folder contains the pre-compiled executable file namedReactCodeGenerator.exe
. -
Place the Swagger Specification File
Ensure yourswagger.json
file is ready, as you will need to provide its path when running the utility.
-
Open Command Prompt
PressWin + R
, typecmd
, and press Enter to open the Command Prompt. -
Navigate to the App Directory
Use thecd
command to navigate to the folder containingReactCodeGenerator.exe
. For example:cd path\to\your\app\folder
-
Run the Utility
Execute the following command, replacingpath\to\swagger.json
with the path to your OpenAPI specification file andComponentName
with the desired component name:ReactCodeGenerator.exe "path\to\swagger.json" "ComponentName" "typename"
Example:
ReactCodeGenerator.exe "D:\rssb\repos\openapi.json" location location
After running the utility, the generated files will be placed in the appropriate folders according to the structure required for your React project. These files include:
ComponentName.types.ts
ComponentName.api.ts
ComponentName.slice.ts
ComponentName.saga.ts
- Container and content files for the component
-
Copy the Generated Files
Copy the generated files from the output folder into the appropriate directories within your React project. -
Update Your Project
Add the necessary imports in your Redux store and sagas to integrate the generated slices and sagas. -
Build and Run
After integrating the files, build and run your React project as usual.
If you encounter any issues while using the utility or integrating the generated files, ensure that your swagger.json
is correctly formatted and that the paths provided are accurate.
This formatted README.md
should be easy to read and follow, ensuring that users can run the utility smoothly without compiling the code themselves.