-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat(clients): generate code snippets from cts #2511
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ae5b060
feat(clients): generate code snippets from cts
shortcuts 61a0390
fix: skip for non supported
shortcuts d61b700
trigger
shortcuts 95ea559
feat: add testName
shortcuts a9afbe4
fix: store snippets in artifact
shortcuts 0daeaf2
feat(generators): add snippets generator
shortcuts d539d24
fix: paths to partial templates
shortcuts d7c1c8b
Merge branch 'main' into feat/code-snippets-from-cts
shortcuts fb026e9
fix: paths to partial templates for java
shortcuts 39ae642
feat: js templates
shortcuts 46c88a7
chore: java cleanup
shortcuts 74bbf79
dynamic artifact stuff
shortcuts a02568c
feat: gen for php
shortcuts e47fca3
fix: formatters
shortcuts 6f14852
feat: gen for java
shortcuts e29d9aa
fix: formatter
shortcuts e406dee
fix: formatter for js snippets
shortcuts c96601c
fix: move logic in generator
shortcuts 7b30c6b
Merge branch 'main' into feat/code-snippets-from-cts
shortcuts 1624f04
fix: csharp
shortcuts 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
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.
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.
I think this should be in a totally different file, like
scripts/snippets/generate.ts
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.
I did not yet created the CLI stuff, I know you want to do it :D