How abhisheksuryawanshi/smartapi works
SmartAPI turns JSON samples or OpenAPI schemas into typed Swift API layers, then supplies a runtime for requests, pagination, caching, and optional UI/mutation features. The main journey is sample/spec → generated wrapper and models → configured request → fetched and paginated data → SwiftUI presentation. The runtime and macro internals are only partially sampled, so their links reflect the README and explicit source documentation; uncertain implementation wiring is omitted.
Main entry points: SmartClient.swift HTTP client · PaginatedLoader.swift Paginated loader · SmartAPIBundle.swift smartapi-bundle · SmartAPIMacro.swift @SmartAPI macro
Components 24
Schema generation
- smartapi-bundle
Sources/smartapi-bundle/SmartAPIBundle.swift - Fixture processor
Sources/smartapi-bundle/FixtureProcessor.swift - OpenAPI importer
Sources/SmartAPIImporter/OpenAPIImporter.swift - Wrapper renderer
Sources/SmartAPIImporter/WrapperRenderer.swift - @SmartAPI macro
Sources/SmartAPIMacros/SmartAPIMacro.swift - JSON inference
Sources/SmartAPIMacros/JSONInference.swift - Code generator
Sources/SmartAPIMacros/CodeGenerator.swift - Typed models
Sources/SmartAPIMacros/CodeGenerator.swift
API runtime
- Endpoint catalog
Sources/SmartAPI/SmartEndpoint.swift - Request query
Sources/SmartAPI/SmartQuery.swift - HTTP client
Sources/SmartAPI/SmartClient.swift
Pagination and UI
- Paginated loader
Sources/SmartAPI/PaginatedLoader.swift - Pagination strategy
Sources/SmartAPI/PaginationStrategy.swift - SwiftUI views
Sources/SmartAPI/SmartView.swift
Production features
- Response cache
Sources/SmartAPI/SmartCache.swift - Authorization provider
Sources/SmartAPI/AuthorizationProvider.swift - Retry policy
Sources/SmartAPI/RetryPolicy.swift - Request coalescer
Sources/SmartAPI/RequestCoalescer.swift - Request observer
Sources/SmartAPI/SmartAPIObserver.swift - Model mutator
Sources/SmartAPI/SmartAPIMutator.swift
Other components
- App developer
- JSON sample
- OpenAPI spec
- API service
Connections 31
- App developer → JSON sample: provides sample
- App developer → OpenAPI spec: provides spec
- JSON sample → @SmartAPI macro: annotates model
- JSON sample → smartapi-bundle: fixture input
- smartapi-bundle → Fixture processor: dispatches fixtures
- Fixture processor → Wrapper renderer: renders wrapper
- OpenAPI spec → smartapi-bundle: spec input
- smartapi-bundle → OpenAPI importer: dispatches import
- OpenAPI importer → Wrapper renderer: renders wrappers
- Wrapper renderer → @SmartAPI macro: emits annotation
- @SmartAPI macro → JSON inference: infers schema
- @SmartAPI macro → Code generator: generates declarations
- JSON inference → Code generator: supplies type tree
- Code generator → Typed models: emits models
- Typed models → Endpoint catalog: types responses
- App developer → Endpoint catalog: configures endpoints
- Endpoint catalog → HTTP client: calls endpoint
- App developer → Request query: configures request
- Request query → HTTP client: describes request
- HTTP client → API service: sends HTTP
- API service → HTTP client: returns response
- Paginated loader → HTTP client: fetches pages
- Paginated loader → Pagination strategy: advances state
- Pagination strategy → Paginated loader: supplies page rules
- SwiftUI views → Paginated loader: loads items
- HTTP client → Authorization provider: gets credentials
- HTTP client → Retry policy: applies retries
- HTTP client → Request coalescer: coalesces reads
- Paginated loader → Response cache: uses cache
- HTTP client → Request observer: reports activity
- Model mutator → HTTP client: sends mutations