diff --git a/bin/copy-examples-filtered b/bin/copy-examples-filtered new file mode 100755 index 000000000..424a9b809 --- /dev/null +++ b/bin/copy-examples-filtered @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# +# Copies example files from src_dir to dst_dir, skipping any whose operationId +# exists in openapi-raw.yaml but not in openapi-sdk.yaml (i.e. endpoints hidden +# from the SDK via the x-hideOn: sdk attribute). Matching is by PascalCase +# filename: an operationId "templateUpdate" maps to "TemplateUpdateExample.". + +set -e + +DIR=$(cd "$(dirname "$0")" && pwd) +ROOT_DIR="${DIR}/.." + +SRC_DIR="$1" +DST_DIR="$2" +EXT="$3" + +if [[ -z "$SRC_DIR" || -z "$DST_DIR" || -z "$EXT" ]]; then + printf "Usage: copy-examples-filtered \n" + exit 1 +fi + +HIDDEN_PASCALS=() +while IFS= read -r OP; do + [ -z "$OP" ] && continue + HIDDEN_PASCALS+=("$(echo "${OP:0:1}" | tr 'a-z' 'A-Z')${OP:1}") +done < <(comm -23 \ + <(grep 'operationId:' "${ROOT_DIR}/openapi-raw.yaml" | sed 's/.*operationId: //' | sort) \ + <(grep 'operationId:' "${ROOT_DIR}/openapi-sdk.yaml" | sed 's/.*operationId: //' | sort)) + +for FILE in "${SRC_DIR}"/*."${EXT}"; do + [ -f "$FILE" ] || continue + BASENAME=$(basename "$FILE" ".$EXT") + + SKIP=0 + for PASCAL in "${HIDDEN_PASCALS[@]}"; do + if [ "$BASENAME" = "${PASCAL}Example" ]; then + SKIP=1 + printf " Skipping (hidden from SDK): %s\n" "$(basename "$FILE")" + break + fi + done + + if [ $SKIP -eq 0 ]; then + cp "$FILE" "$DST_DIR/" + fi +done diff --git a/build b/build index f706758a2..470d514b3 100755 --- a/build +++ b/build @@ -14,11 +14,11 @@ printf "\n" bash "${DIR}/bin/php" ./bin/generate-oas.php -cp "${DIR}/examples/"*.cs "${DIR}/sandbox/dotnet/src/Dropbox.SignSandbox/" -cp "${DIR}/examples/"*.java "${DIR}/sandbox/java/src/main/java/com/dropbox/sign_sandbox/" -cp "${DIR}/examples/"*.php "${DIR}/sandbox/php/src/" -cp "${DIR}/examples/"*.py "${DIR}/sandbox/python/src/" -cp "${DIR}/examples/"*.rb "${DIR}/sandbox/ruby/src/" -cp "${DIR}/examples/"*.ts "${DIR}/sandbox/node/src/" +"${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${DIR}/sandbox/dotnet/src/Dropbox.SignSandbox" cs +"${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${DIR}/sandbox/java/src/main/java/com/dropbox/sign_sandbox" java +"${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${DIR}/sandbox/php/src" php +"${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${DIR}/sandbox/python/src" py +"${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${DIR}/sandbox/ruby/src" rb +"${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${DIR}/sandbox/node/src" ts printf "Success!\n" diff --git a/copy-sdks b/copy-sdks index c0f48920b..2fffe8b51 100755 --- a/copy-sdks +++ b/copy-sdks @@ -122,17 +122,17 @@ function copy_files() cp -r "${DIR}/openapi-sdk.yaml" "${SDK_DIR}/openapi-sdk.yaml" if [[ "${SDK}" == "dotnet" ]]; then - cp -r "${DIR}/examples/"*.cs "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" cs elif [[ "${SDK}" == "java-v2" ]] || [[ "${SDK}" == "java-v1" ]]; then - cp -r "${DIR}/examples/"*.java "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" java elif [[ "${SDK}" == "node" ]]; then - cp -r "${DIR}/examples/"*.ts "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" ts elif [[ "${SDK}" == "php" ]]; then - cp -r "${DIR}/examples/"*.php "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" php elif [[ "${SDK}" == "python" ]]; then - cp -r "${DIR}/examples/"*.py "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" py elif [[ "${SDK}" == "ruby" ]]; then - cp -r "${DIR}/examples/"*.rb "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" rb fi php "${DIR}/bin/update-sdk-version.php" ${SDK} ${VERSION} diff --git a/generate-sdks b/generate-sdks index de40ae11b..2fff0366b 100755 --- a/generate-sdks +++ b/generate-sdks @@ -155,17 +155,17 @@ function copy_examples() mkdir -p "${SDK_DIR}/examples" if [[ "${SDK}" == "dotnet" ]]; then - cp -r "${DIR}/sandbox/dotnet/src/Dropbox.SignSandbox/"*.cs "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/sandbox/dotnet/src/Dropbox.SignSandbox" "${SDK_DIR}/examples" cs elif [[ "${SDK}" == "java-v2" || "${SDK}" == "java-v1" ]]; then - cp -r "${DIR}/sandbox/java/src/main/java/com/dropbox/sign_sandbox/"*.java "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/sandbox/java/src/main/java/com/dropbox/sign_sandbox" "${SDK_DIR}/examples" java elif [[ "${SDK}" == "node" ]]; then - cp -r "${DIR}/sandbox/node/src/"*.ts "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/sandbox/node/src" "${SDK_DIR}/examples" ts elif [[ "${SDK}" == "php" ]]; then - cp -r "${DIR}/sandbox/php/src/"*.php "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/sandbox/php/src" "${SDK_DIR}/examples" php elif [[ "${SDK}" == "python" ]]; then - cp -r "${DIR}/sandbox/python/src/"*.py "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/sandbox/python/src" "${SDK_DIR}/examples" py elif [[ "${SDK}" == "ruby" ]]; then - cp -r "${DIR}/sandbox/ruby/src/"*.rb "${SDK_DIR}/examples/" + "${DIR}/bin/copy-examples-filtered" "${DIR}/sandbox/ruby/src" "${SDK_DIR}/examples" rb fi } diff --git a/openapi-raw.yaml b/openapi-raw.yaml index a403e49c4..132929285 100644 --- a/openapi-raw.yaml +++ b/openapi-raw.yaml @@ -7289,6 +7289,7 @@ paths: x-hideOn: - doc - sdk + x-beta: closed '/template/update_files/{template_id}': post: tags: diff --git a/sandbox/dotnet/src/Dropbox.SignSandbox/TemplateUpdateExample.cs b/sandbox/dotnet/src/Dropbox.SignSandbox/TemplateUpdateExample.cs deleted file mode 100644 index 0fc66e5ed..000000000 --- a/sandbox/dotnet/src/Dropbox.SignSandbox/TemplateUpdateExample.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text.Json; - -using Dropbox.Sign.Api; -using Dropbox.Sign.Client; -using Dropbox.Sign.Model; - -namespace Dropbox.SignSandbox; - -public class TemplateUpdateExample -{ - public static void Run() - { - var config = new Configuration(); - config.Username = "YOUR_API_KEY"; - // config.AccessToken = "YOUR_ACCESS_TOKEN"; - - var formFields1 = new SubUpdateFormField( - apiId: "uniqueIdHere_1", - name: "New name 1" - ); - - var formFields2 = new SubUpdateFormField( - apiId: "uniqueIdHere_2", - name: "New name 2" - ); - - var formFields = new List - { - formFields1, - formFields2, - }; - - var templateUpdateRequest = new TemplateUpdateRequest( - title: "Test Title", - subject: "Test Subject", - message: "Test Message", - ccRoles: [ - "CC Role 1", - "CC Role 2", - ], - formFields: formFields - ); - - try - { - var response = new TemplateApi(config).TemplateUpdate( - templateId: "f57db65d3f933b5316d398057a36176831451a35", - templateUpdateRequest: templateUpdateRequest - ); - - Console.WriteLine(response); - } - catch (ApiException e) - { - Console.WriteLine("Exception when calling TemplateApi#TemplateUpdate: " + e.Message); - Console.WriteLine("Status Code: " + e.ErrorCode); - Console.WriteLine(e.StackTrace); - } - } -} diff --git a/sandbox/java/src/main/java/com/dropbox/sign_sandbox/TemplateUpdateExample.java b/sandbox/java/src/main/java/com/dropbox/sign_sandbox/TemplateUpdateExample.java deleted file mode 100644 index 25c622553..000000000 --- a/sandbox/java/src/main/java/com/dropbox/sign_sandbox/TemplateUpdateExample.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.dropbox.sign_sandbox; - -import com.dropbox.sign.ApiException; -import com.dropbox.sign.Configuration; -import com.dropbox.sign.api.*; -import com.dropbox.sign.auth.*; -import com.dropbox.sign.JSON; -import com.dropbox.sign.model.*; - -import java.io.File; -import java.math.BigDecimal; -import java.time.LocalDate; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class TemplateUpdateExample -{ - public static void main(String[] args) - { - var config = Configuration.getDefaultApiClient(); - ((HttpBasicAuth) config.getAuthentication("api_key")).setUsername("YOUR_API_KEY"); - // ((HttpBearerAuth) config.getAuthentication("oauth2")).setBearerToken("YOUR_ACCESS_TOKEN"); - - var formFields1 = new SubUpdateFormField(); - formFields1.apiId("uniqueIdHere_1"); - formFields1.name("New name 1"); - - var formFields2 = new SubUpdateFormField(); - formFields2.apiId("uniqueIdHere_2"); - formFields2.name("New name 2"); - - var formFields = new ArrayList(List.of ( - formFields1, - formFields2 - )); - - var templateUpdateRequest = new TemplateUpdateRequest(); - templateUpdateRequest.title("Test Title"); - templateUpdateRequest.subject("Test Subject"); - templateUpdateRequest.message("Test Message"); - templateUpdateRequest.ccRoles(List.of ( - "CC Role 1", - "CC Role 2" - )); - templateUpdateRequest.formFields(formFields); - - try - { - var response = new TemplateApi(config).templateUpdate( - "f57db65d3f933b5316d398057a36176831451a35", // templateId - templateUpdateRequest - ); - - System.out.println(response); - } catch (ApiException e) { - System.err.println("Exception when calling TemplateApi#templateUpdate"); - System.err.println("Status code: " + e.getCode()); - System.err.println("Reason: " + e.getResponseBody()); - System.err.println("Response headers: " + e.getResponseHeaders()); - e.printStackTrace(); - } - } -} diff --git a/sandbox/node/src/TemplateUpdateExample.ts b/sandbox/node/src/TemplateUpdateExample.ts deleted file mode 100644 index 92c8d4566..000000000 --- a/sandbox/node/src/TemplateUpdateExample.ts +++ /dev/null @@ -1,43 +0,0 @@ -import * as fs from 'fs'; -import api from "@dropbox/sign" -import models from "@dropbox/sign" - -const apiCaller = new api.TemplateApi(); -apiCaller.username = "YOUR_API_KEY"; -// apiCaller.accessToken = "YOUR_ACCESS_TOKEN"; - -const formFields1: models.SubUpdateFormField = { - apiId: "uniqueIdHere_1", - name: "New name 1", -}; - -const formFields2: models.SubUpdateFormField = { - apiId: "uniqueIdHere_2", - name: "New name 2", -}; - -const formFields = [ - formFields1, - formFields2, -]; - -const templateUpdateRequest: models.TemplateUpdateRequest = { - title: "Test Title", - subject: "Test Subject", - message: "Test Message", - ccRoles: [ - "CC Role 1", - "CC Role 2", - ], - formFields: formFields, -}; - -apiCaller.templateUpdate( - "f57db65d3f933b5316d398057a36176831451a35", // templateId - templateUpdateRequest, -).then(response => { - console.log(response.body); -}).catch(error => { - console.log("Exception when calling TemplateApi#templateUpdate:"); - console.log(error.body); -}); diff --git a/sandbox/php/src/TemplateUpdateExample.php b/sandbox/php/src/TemplateUpdateExample.php deleted file mode 100644 index c827bc301..000000000 --- a/sandbox/php/src/TemplateUpdateExample.php +++ /dev/null @@ -1,46 +0,0 @@ -setUsername("YOUR_API_KEY"); -// $config->setAccessToken("YOUR_ACCESS_TOKEN"); - -$form_fields_1 = (new Dropbox\Sign\Model\SubUpdateFormField()) - ->setApiId("uniqueIdHere_1") - ->setName("New name 1"); - -$form_fields_2 = (new Dropbox\Sign\Model\SubUpdateFormField()) - ->setApiId("uniqueIdHere_2") - ->setName("New name 2"); - -$form_fields = [ - $form_fields_1, - $form_fields_2, -]; - -$template_update_request = (new Dropbox\Sign\Model\TemplateUpdateRequest()) - ->setTitle("Test Title") - ->setSubject("Test Subject") - ->setMessage("Test Message") - ->setCcRoles([ - "CC Role 1", - "CC Role 2", - ]) - ->setFormFields($form_fields); - -try { - $response = (new Dropbox\Sign\Api\TemplateApi(config: $config))->templateUpdate( - template_id: "f57db65d3f933b5316d398057a36176831451a35", - template_update_request: $template_update_request, - ); - - print_r($response); -} catch (Dropbox\Sign\ApiException $e) { - echo "Exception when calling TemplateApi#templateUpdate: {$e->getMessage()}"; -} diff --git a/sandbox/python/src/TemplateUpdateExample.py b/sandbox/python/src/TemplateUpdateExample.py deleted file mode 100644 index 39e767acb..000000000 --- a/sandbox/python/src/TemplateUpdateExample.py +++ /dev/null @@ -1,47 +0,0 @@ -import json -from datetime import date, datetime -from pprint import pprint - -from dropbox_sign import ApiClient, ApiException, Configuration, api, models - -configuration = Configuration( - username="YOUR_API_KEY", - # access_token="YOUR_ACCESS_TOKEN", -) - -with ApiClient(configuration) as api_client: - form_fields_1 = models.SubUpdateFormField( - api_id="uniqueIdHere_1", - name="New name 1", - ) - - form_fields_2 = models.SubUpdateFormField( - api_id="uniqueIdHere_2", - name="New name 2", - ) - - form_fields = [ - form_fields_1, - form_fields_2, - ] - - template_update_request = models.TemplateUpdateRequest( - title="Test Title", - subject="Test Subject", - message="Test Message", - cc_roles=[ - "CC Role 1", - "CC Role 2", - ], - form_fields=form_fields, - ) - - try: - response = api.TemplateApi(api_client).template_update( - template_id="f57db65d3f933b5316d398057a36176831451a35", - template_update_request=template_update_request, - ) - - pprint(response) - except ApiException as e: - print("Exception when calling TemplateApi#template_update: %s\n" % e) diff --git a/sandbox/ruby/src/TemplateUpdateExample.rb b/sandbox/ruby/src/TemplateUpdateExample.rb deleted file mode 100644 index e0332ea8f..000000000 --- a/sandbox/ruby/src/TemplateUpdateExample.rb +++ /dev/null @@ -1,41 +0,0 @@ -require "json" -require "dropbox-sign" - -Dropbox::Sign.configure do |config| - config.username = "YOUR_API_KEY" - # config.access_token = "YOUR_ACCESS_TOKEN" -end - -form_fields_1 = Dropbox::Sign::SubUpdateFormField.new -form_fields_1.api_id = "uniqueIdHere_1" -form_fields_1.name = "New name 1" - -form_fields_2 = Dropbox::Sign::SubUpdateFormField.new -form_fields_2.api_id = "uniqueIdHere_2" -form_fields_2.name = "New name 2" - -form_fields = [ - form_fields_1, - form_fields_2, -] - -template_update_request = Dropbox::Sign::TemplateUpdateRequest.new -template_update_request.title = "Test Title" -template_update_request.subject = "Test Subject" -template_update_request.message = "Test Message" -template_update_request.cc_roles = [ - "CC Role 1", - "CC Role 2", -] -template_update_request.form_fields = form_fields - -begin - response = Dropbox::Sign::TemplateApi.new.template_update( - "f57db65d3f933b5316d398057a36176831451a35", # template_id - template_update_request, - ) - - p response -rescue Dropbox::Sign::ApiError => e - puts "Exception when calling TemplateApi#template_update: #{e}" -end