Moonglade

Modern Markdown blogging with AI-powered localization and search.

Tag: github

RSS

OpenAPI client generation

This article documents the selection process and practical experience of automatically generating SDKs based on OpenAPI metadata. The author compared three libraries: `autorest`, `swagger-codegen-cli`, and `@hey-api/openapi-ts`, ultimately choosing the latter due to its superior performance in frontend environment compatibility, code conciseness, and type reuse. This choice effectively reduces the workload of manually writing request code and improves development efficiency. Using a NestJS backend and Vue frontend as examples, the article details the complete technical pipeline: configuring `nest-cli.json` to extract DTO and Entity types, utilizing a GitHub Actions pipeline to start the service in a CI environment to retrieve metadata, invoking `@hey-api/openapi-ts` to generate the SDK, and pushing it to a separate sub-repository. The frontend wraps the `@hey-api/client-fetch` client to implement unified authentication interception and error handling, directly importing the generated types and functions within Pinia Stores to achieve type safety and code reuse. This workflow not only reduces the collaboration cost between frontend and backend teams but also minimizes format errors through standardized interface definitions. Although the currently auto-generated parameter validation feature has limitations, the overall solution offers significant advantages in terms of type safety and development efficiency.

Views 385
2024 ci-cd github openapi study swagger vue work

AutoQuery Usage and Deployment (GitHub Actions)

This article introduces the rapid development workflow based on the AutoQuery framework, covering key steps from environment initialization to production deployment. First, the `x` command-line tool is installed via `dotnet tool`, and the `x new` command is used to create a Web project. `autocrudgen` is then leveraged to automatically generate SQLite database models and basic code, simplifying backend development tasks. The deployment section details how to configure Docker and Docker Compose on an Ubuntu 22.04 server, including specific commands for updating system sources, adding the official Docker GPG key, and installing the latest CE version. The article also demonstrates how to use `x mix build` to generate an Nginx proxy configuration script, upload it to the server via `scp`, and start services using `docker compose` commands, thereby implementing an automated deployment solution based on GitHub Actions. Additionally, the text provides practical details such as Let's Encrypt email configuration, SSH connection parameters, and user permission settings, aiming to help developers efficiently build and deploy AutoQuery-based applications. A link to a related video tutorial is provided at the end for further learning.

Views 78
.Net ci-cd devops docker github nginx