Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public void addSupportingFiles(List<SupportingFile> supportingFiles, String outp

@Override
public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation> operations, Map<String, Object> bundle) throws Exception {
if (this.client.equals("search")) {
bundle.put("isSearchClient", true);
}
bundle.put("isSyncClient", true);
// nothing to do here, the mustache uses dynamicSnippets lambda
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ public void addDataToBundle(Map<String, Object> bundle) throws GeneratorExceptio

@Override
public void addSnippetsSupportingFiles(List<SupportingFile> supportingFiles, String output) {
supportingFiles.add(new SupportingFile("snippets/Package.mustache", output + "/swift", "Package.swift"));
supportingFiles.add(new SupportingFile("snippets/.swiftformat.mustache", output + "/swift", ".swiftformat"));
supportingFiles.add(new SupportingFile("snippets/.gitignore.mustache", output + "/swift", ".gitignore"));

if (output.equals("snippets")) {
supportingFiles.add(new SupportingFile("snippets/Package.mustache", output + "/swift", "Package.swift"));
} else if (output.equals("guides")) {
supportingFiles.add(new SupportingFile("guides/Package.mustache", output + "/swift", "Package.swift"));
}
}
}
9 changes: 9 additions & 0 deletions guides/swift/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Package.resolved
2 changes: 1 addition & 1 deletion scripts/buildLanguages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function buildLanguage(language: Language, gens: Generator[], buildType: B
break;
case 'swift':
// make this work in the playground
if (buildType === 'client') {
if (buildType !== 'playground') {
await run('swift build -Xswiftc -suppress-warnings', { cwd, language });
}
break;
Expand Down
34 changes: 34 additions & 0 deletions templates/csharp/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Text.Json;
using System.Net.Http;
using System.Collections.Generic;

{{> snippets/import}}

class Program
{
public static async Task Main(string[] args)
{
// read json file from url
var url = "https://dashboard.algolia.com/sample_datasets/movie.json";
var httpClient = new HttpClient();
var response = await httpClient.GetAsync(url);
var content = await response.Content.ReadAsStringAsync();

// parse json
var movies = JsonSerializer.Deserialize<List<dynamic>>(content);

// initiate client and index
{{> snippets/init}}

// push data to algolia
try
{
var result = {{#dynamicSnippet}}saveObjectsMovies{{/dynamicSnippet}};
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
Loading
Loading