-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Typescript Fetch] New optional mode with redux saga & immutablejs (saga & records) #8578
Merged
wing328
merged 47 commits into
OpenAPITools:master
from
bflamand:typescript-saga-immutablejs
Jun 23, 2021
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
ac55b6c
first commit: add cli option for saga and records. Added dummy sagas.…
bflamand-work 61a3033
More progress with default values. First prototype for isEntity and i…
bflamand-work 2e3a04e
record generation complete
bflamand-work 9411143
record generation complete
bflamand-work 6e867ee
progress with saga generation
bflamand-work 3da2805
progress with saga generation
bflamand-work 7b42777
Merge pull request #1 from OpenAPITools/master
bflamand 9a3160c
first fully working saga generation
bflamand-work 84c702c
Merge remote-tracking branch 'origin/master' into typescript-saga-imm…
bflamand-work 5554245
merge with latest master
bflamand-work f8030fb
removed unneeded "items" properties.
bflamand-work 8f33935
moved global CodegenModel modifications into subclass ExtendedCodegen…
bflamand-work f387d06
moved global CodegenOperation modifications into subclass ExtendedCod…
bflamand-work c586da2
moved global CodegenProperty modifications into subclass ExtendedCode…
bflamand-work b273409
moved global CodegenParameter modifications into subclass ExtendedCod…
bflamand-work 9b48cf2
added the missing "allSagas" export.
bflamand-work 1796282
renamed & reworked "meta data response" flags to a more useful genera…
bflamand-work a82ff31
added vendor flag keepAsJSObject as escape hatch to support circular …
bflamand-work 549797d
added autodetection for passthrough to simplify standardised specs.
bflamand-work 1706006
fix small issue with passthrough void
bflamand-work 32c97a4
fix small issues with passthrough void and missing passthrough import…
bflamand-work e6c5ef3
fix small issues with passthrough void and missing passthrough import…
bflamand-work ea5a5eb
Merge pull request #3 from OpenAPITools/master
bflamand e86c81f
Merge remote-tracking branch 'origin/master' into typescript-saga-imm…
bflamand-work 9160502
Added "reservedRecordField" feature to support remapping fields names…
bflamand-work a77f17e
added uniqueId inference. Fix small generation when uniqueId property…
bflamand-work 8925de1
removed feature "reservedRecordField" and replaced it with existing b…
bflamand-work 090150b
Changed api recType names to make them less likely to cause name conf…
bflamand-work 76eef30
Moved location of ApiEntities related files and fix issues with exports.
bflamand-work 47e06dd
Merge pull request #4 from OpenAPITools/master
bflamand 8e2b99c
merge master
bflamand-work 0e2b574
- merge latest master
bflamand-work 1c67357
- missing ganarate sampless
bflamand-work 1fb2e4f
Merge pull request #5 from OpenAPITools/master
bflamand 639d687
Merge remote-tracking branch 'origin/master' into typescript-saga-imm…
bflamand-work 6ab1fba
- Modified way to export apiEntitiesSelectpr to reduce typescript ana…
bflamand-work bff46e0
- added markErrorsAsHandled property to api sagas. Increased typescri…
bflamand-work e72f84f
- fix bug in saga interfaces. Upgraded to typescript "strict" mode to…
bflamand-work b13159b
- added optional id for apiEntity selectors. Added toInlined() suppor…
bflamand-work 33cf0d4
- minor tweak for apiEntitySelector to accept null id
bflamand-work 0389c3a
- minor tweak for apiEntitySelector
bflamand-work b2bfad9
Merge pull request #6 from OpenAPITools/master
bflamand d87cff8
Merge remote-tracking branch 'origin/master' into typescript-saga-imm…
bflamand-work ea9b4ae
- runned ensure up to date.
bflamand-work ace4139
Revert "- runned ensure up to date."
bflamand-work bf12bb2
- runned ensure up to date.
bflamand-work ec78ed9
- runned ensure up to date.
bflamand-work File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
generatorName: typescript-fetch | ||
outputDir: samples/client/petstore/typescript-fetch/builds/sagas-and-records | ||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-saga-and-records.yaml | ||
additionalProperties: | ||
npmVersion: 1.0.0 | ||
npmName: '@openapitools/typescript-fetch-petstore' | ||
npmRepository: https://skimdb.npmjs.com/registry | ||
useSingleRequestParameter: false | ||
supportsES6: true | ||
typescriptThreePlus: true | ||
sagasAndRecords: true | ||
detectPassthroughModelsWithSuffixAndField: 'Response.data' | ||
inferUniqueIdFromNameSuffix: true | ||
inferEntityFromUniqueIdWithName: id | ||
packageAsSourceOnlyLibrary: false | ||
snapshot: false |
This file contains 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
This file contains 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
1,106 changes: 1,060 additions & 46 deletions
1,106
...erator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
Large diffs are not rendered by default.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
modules/openapi-generator/src/main/resources/typescript-fetch/ApiEntitiesRecord.mustache
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {Map, Record, RecordOf} from 'immutable'; | ||
|
||
import { | ||
{{#models}} | ||
{{#model}} | ||
{{#isEntity}} | ||
{{classname}}RecordEntity, | ||
{{/isEntity}} | ||
{{/model}} | ||
{{/models}} | ||
} from "./models" | ||
|
||
export const ApiEntitiesRecordProps = { | ||
recType: "ApiEntitiesRecord" as "ApiEntitiesRecord", | ||
{{#models}} | ||
{{#model}} | ||
{{#isEntity}} | ||
{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}: ({{classname}}RecordEntity(), Map<string, {{classname}}RecordEntity>()), | ||
{{/isEntity}} | ||
{{/model}} | ||
{{/models}} | ||
}; | ||
|
||
export type ApiEntitiesRecordPropsType = typeof ApiEntitiesRecordProps; | ||
export const ApiEntitiesRecord = Record(ApiEntitiesRecordProps, ApiEntitiesRecordProps.recType); | ||
export type ApiEntitiesRecord = RecordOf<ApiEntitiesRecordPropsType>; |
21 changes: 21 additions & 0 deletions
21
modules/openapi-generator/src/main/resources/typescript-fetch/ApiEntitiesReducer.mustache
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {ApiEntitiesRecord} from "./ApiEntitiesRecord"; | ||
import {ReducerBuilder} from "redux-ts-simple"; | ||
import {normalizedEntities} from "./runtimeSagasAndRecords"; | ||
|
||
export const ApiEntitiesReducer = new ReducerBuilder(ApiEntitiesRecord()) | ||
.on(normalizedEntities, (state, action): ApiEntitiesRecord => { | ||
const {entities} = action.payload; | ||
return state.withMutations(mutableState => { | ||
for (const entityKey in entities) { | ||
const entityMap = entities[entityKey]; | ||
const currentEntityMap = mutableState.get(entityKey as any); | ||
if (currentEntityMap) { | ||
let mergedEntityMap = currentEntityMap.mergeDeep(entityMap); | ||
if (!mergedEntityMap.equals(currentEntityMap)) { | ||
mutableState.set(entityKey as any, mergedEntityMap); | ||
} | ||
} | ||
} | ||
}); | ||
}) | ||
.build(); |
5 changes: 5 additions & 0 deletions
5
modules/openapi-generator/src/main/resources/typescript-fetch/ApiEntitiesSelectors.mustache
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export let getApiEntitiesState: (state: any) => any = (state: any) => state.app.apiEntities; | ||
|
||
export function setApiEntitiesStateGetter(getter: (state: any) => any) { // Use this to customize the location where you have placed your ApiEntitiesRecord in your project. | ||
getApiEntitiesState = getter; | ||
} |
19 changes: 19 additions & 0 deletions
19
modules/openapi-generator/src/main/resources/typescript-fetch/allSagas.mustache
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {all, fork} from "redux-saga/effects"; | ||
|
||
import { | ||
{{#apiInfo}} | ||
{{#apis}} | ||
{{#lambda.camelcase}}{{classFilename}}{{/lambda.camelcase}}AllSagas, | ||
{{/apis}} | ||
{{/apiInfo}} | ||
} from "./"; | ||
|
||
export function *allApiSagas() { | ||
yield all([ | ||
{{#apiInfo}} | ||
{{#apis}} | ||
fork({{#lambda.camelcase}}{{classFilename}}{{/lambda.camelcase}}AllSagas), | ||
{{/apis}} | ||
{{/apiInfo}} | ||
]); | ||
} |
7 changes: 7 additions & 0 deletions
7
modules/openapi-generator/src/main/resources/typescript-fetch/apis.index.mustache
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
{{#useSagaAndRecords}} | ||
export * from './SagaApiManager' | ||
export * from './allSagas' | ||
{{/useSagaAndRecords}} | ||
{{#apiInfo}} | ||
{{#apis}} | ||
{{#operations}} | ||
export * from './{{ classFilename }}'; | ||
{{#useSagaAndRecords}} | ||
export * from './{{{ classFilename }}}Sagas'; | ||
{{/useSagaAndRecords}} | ||
{{/operations}} | ||
{{/apis}} | ||
{{/apiInfo}} |
6 changes: 6 additions & 0 deletions
6
modules/openapi-generator/src/main/resources/typescript-fetch/index.mustache
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use OpenAPI 3.0 spec instead as we're doing the same for other samples from openapi 2.0 to 3.0 spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this can wait, I would prefer to take a look at this at a later time. I am not sure of the implications of changing this. It is probably very easy, but I am not sure. Would prefer to proceeed with a first merge and upgrade in a next phase. See my additional comments below regarding the futur plan for this upgrade.