-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clients): generate code snippets from cts (#2511)
- Loading branch information
Showing
85 changed files
with
497 additions
and
158 deletions.
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
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
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
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
11 changes: 1 addition & 10 deletions
11
generators/src/main/java/com/algolia/codegen/cts/manager/PhpCTSManager.java
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,14 +1,5 @@ | ||
package com.algolia.codegen.cts.manager; | ||
|
||
import com.algolia.codegen.exceptions.GeneratorException; | ||
import java.util.*; | ||
import org.openapitools.codegen.SupportingFile; | ||
|
||
public class PhpCTSManager implements CTSManager { | ||
|
||
@Override | ||
public void addSupportingFiles(List<SupportingFile> supportingFiles) {} | ||
|
||
@Override | ||
public void addDataToBundle(Map<String, Object> bundle) throws GeneratorException {} | ||
} | ||
public class PhpCTSManager implements CTSManager {} |
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
50 changes: 50 additions & 0 deletions
50
generators/src/main/java/com/algolia/codegen/cts/snippets/SnippetsGenerator.java
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,50 @@ | ||
package com.algolia.codegen.cts.snippets; | ||
|
||
import com.algolia.codegen.cts.tests.*; | ||
import com.algolia.codegen.utils.*; | ||
import java.io.File; | ||
import java.util.*; | ||
import org.openapitools.codegen.CodegenModel; | ||
import org.openapitools.codegen.CodegenOperation; | ||
import org.openapitools.codegen.SupportingFile; | ||
|
||
public class SnippetsGenerator extends TestsRequest { | ||
|
||
public SnippetsGenerator(String language, String client) { | ||
super(language, client); | ||
} | ||
|
||
@Override | ||
public boolean available() { | ||
File templates = new File("templates/" + language + "/snippets/method.mustache"); | ||
return templates.exists(); | ||
} | ||
|
||
@Override | ||
public void addSupportingFiles(List<SupportingFile> supportingFiles, String outputFolder, String extension) { | ||
if (!available()) { | ||
return; | ||
} | ||
|
||
extension = Helpers.getClientConfigField(language, "snippets", "extension"); | ||
outputFolder = Helpers.getClientConfigField(language, "snippets", "outputFolder"); | ||
|
||
if (!outputFolder.equals("")) { | ||
outputFolder = "/" + outputFolder + "/"; | ||
} else { | ||
outputFolder = "/"; | ||
} | ||
|
||
supportingFiles.add( | ||
new SupportingFile( | ||
"snippets/method.mustache", | ||
"snippets/" + language + outputFolder + Helpers.createClientName(client, language) + extension | ||
) | ||
); | ||
} | ||
|
||
@Override | ||
public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation> operations, Map<String, Object> bundle) throws Exception { | ||
super.run(models, operations, bundle); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "javascript-snippets", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"@algolia/client-abtesting": "link:../../clients/algoliasearch-client-javascript/packages/client-abtesting", | ||
"@algolia/client-analytics": "link:../../clients/algoliasearch-client-javascript/packages/client-analytics", | ||
"@algolia/client-common": "link:../../clients/algoliasearch-client-javascript/packages/client-common", | ||
"@algolia/client-insights": "link:../../clients/algoliasearch-client-javascript/packages/client-insights", | ||
"@algolia/client-personalization": "link:../../clients/algoliasearch-client-javascript/packages/client-personalization", | ||
"@algolia/client-query-suggestions": "link:../../clients/algoliasearch-client-javascript/packages/client-query-suggestions", | ||
"@algolia/client-search": "link:../../clients/algoliasearch-client-javascript/packages/client-search", | ||
"@algolia/ingestion": "link:../../clients/algoliasearch-client-javascript/packages/ingestion", | ||
"@algolia/monitoring": "link:../../clients/algoliasearch-client-javascript/packages/monitoring", | ||
"@algolia/recommend": "link:../../clients/algoliasearch-client-javascript/packages/recommend", | ||
"@algolia/requester-node-http": "link:../../clients/algoliasearch-client-javascript/packages/requester-node-http", | ||
"algoliasearch": "link:../../clients/algoliasearch-client-javascript/packages/algoliasearch" | ||
} | ||
} |
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,11 @@ | ||
{ | ||
"extends": "../../config/base.tsconfig.json", | ||
"compilerOptions": { | ||
"typeRoots": ["../../node_modules/@types"], | ||
"types": ["node", "jest"], | ||
"lib": ["dom", "esnext"], | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"], | ||
"exclude": ["dist", "node_modules"] | ||
} |
Oops, something went wrong.