
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
redux-swagger-client
Advanced tools
Swagger middleware for redux
This is an attempt to add asynchronous swagger api calls to redux. It works by dispatching an action that includes the field swagger
that takes a function and passes the swagger client element to that function. If the swagger spec has not yet been parsed, the action will get queued.
note: This module requires redux-thunk Github:
npm install --save github:noh4ck/redux-swagger-client
Package pending:
npm install --save redux-swagger-client
To enable Redux Swagger-client, use applyMiddleware()
:
import { createStore, applyMiddleware } from 'redux'
import swaggerClient from 'redux-swagger-client'
import thunk from 'redux-thunk'
const store = createStore(
rootReducer,
applyMiddleware([
thunk,
swaggerClient({url:'http://petstore.swagger.io/v2/swagger.json'})
])
);
function fetchPet() {
return {
types: ["FETCH_PETS", "FETCH_PETS_SUCCESS", "FETCH_PETS_FAILED"],
swagger: api => api.pet.findPetsByStatus({status: 'available'})
}
}
store.dispatch(fetchPets())
Note, it's also possible to dispatch functions:
function fetchPets_request(json) {
return {
type: 'FETCH_PETS',
receivedAt: Date.now()
}
}
function fetchPets_success(json) {
return {
type: 'FETCH_PETS_SUCCESS',
pets: json.result.body,
receivedAt: Date.now()
}
}
function fetchPets_failure(json) {
return {
type: 'FETCH_PETS_FAILED',
pets: null,
error,
receivedAt: Date.now()
}
}
function fetchPet() {
return {
actions: [fetchPets_request, fetchPets_success, fetchPets_failure],
swagger: api => api.pet.findPetsByStatus({status: 'available'})
}
}
store.dispatch(fetchPets())
FAQs
Swagger middleware for Redux.
The npm package redux-swagger-client receives a total of 29 weekly downloads. As such, redux-swagger-client popularity was classified as not popular.
We found that redux-swagger-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.