Conversation
- Introduce filterUndefined function to remove undefined values from the configuration object - Update mergeConfig function to utilize filtered CLI config, ensuring only non-undefined values override file config values
- Add buildUrl function to replace path parameters in endpoint URLs - Support for single and multiple path parameters - Type-safe parameter replacement with error handling - Update README with examples of using buildUrl - Remove unused placeholder variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Summary
This PR fixes a critical bug with config file reading and adds a new feature for generating API endpoint URL constants with path parameter support.
🐛 Bug Fixes
Config File Reading
falsefor boolean flags)✨ New Features
API Endpoints Generation
--generate-api-endpointsflag to generate API endpoint URL constantsapi/index.tsdirectoryPath Parameter Support
buildUrl()utility function for replacing path parameters in endpoint URLsPathParamstypes📝 Changes
Core Changes
src/config.ts: Fixed config file reading logic with explicit flag detectionsrc/types.ts: AddedgenerateApiEndpointsoption to Config interfacesrc/cli.ts: Added--generate-api-endpointsCLI flagsrc/writer.ts: Added API endpoints file generation logicsrc/generator/api-endpoints-generator.ts: New module for generating endpoint constants andbuildUrlutilityDocumentation
README.mdwith:buildUrlfunction usage examplesswagger-type-parser.config.json.examplewith new option🚀 Usage Examples
Config File
{
"input": "http://localhost:8000/api/v1/openapi.json",
"output": "./src/api/types",
"generateApiEndpoints": true
}### API Endpoints
import { apiEndpoints, buildUrl } from './api/types/api';
// Simple endpoint
await apiClient.post(apiEndpoints.auth.auth_login, payload);
// With path parameters
const url = buildUrl(apiEndpoints.users.users_profile, { user_id: '123' });
// Returns: '/api/v1/users/profile/123'## ✅ Testing
buildUrlfunction handles single and multiple parameters📦 Breaking Changes
None - this is a backward-compatible feature addition and bug fix.