diff --git a/packages/httpsnippet-client-api/src/index.ts b/packages/httpsnippet-client-api/src/index.ts index 2ed2472e..73d7db64 100644 --- a/packages/httpsnippet-client-api/src/index.ts +++ b/packages/httpsnippet-client-api/src/index.ts @@ -164,7 +164,7 @@ const client: Client = { } } else { sdkPackageName = getProjectPrefixFromRegistryUUID(opts.api.registryURI); - sdkVariable = 'sdk'; + sdkVariable = camelCase(sdkPackageName || 'sdk'); } const operationSlugs = foundOperation.url.slugs; @@ -191,7 +191,7 @@ const client: Client = { const serverVars = oas.splitVariables(baseUrl); const serverUrl = serverVars ? oas.url(serverVars.selected, serverVars.variables) : baseUrl; - configData.push(`sdk.server('${serverUrl}');`); + configData.push(`${sdkVariable}.server('${serverUrl}');`); } } diff --git a/packages/httpsnippet-client-api/test/__datasets__/alternate-server/output.js b/packages/httpsnippet-client-api/test/__datasets__/alternate-server/output.js index 35bb5468..4f48bb15 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/alternate-server/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/alternate-server/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/alternate-server'; +import alternateServer from '@api/alternate-server'; -sdk.server('http://dev.local/v2'); -sdk.postGlobal() +alternateServer.server('http://dev.local/v2'); +alternateServer.postGlobal() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/application-form-encoded/output.js b/packages/httpsnippet-client-api/test/__datasets__/application-form-encoded/output.js index 6f29017c..40a2656b 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/application-form-encoded/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/application-form-encoded/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/application-form-encoded'; +import applicationFormEncoded from '@api/application-form-encoded'; -sdk.postAnything({foo: 'bar', hello: 'world'}) +applicationFormEncoded.postAnything({foo: 'bar', hello: 'world'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/application-json/output.js b/packages/httpsnippet-client-api/test/__datasets__/application-json/output.js index 3c094fee..50cc0327 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/application-json/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/application-json/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/application-json'; +import applicationJson from '@api/application-json'; -sdk.postAnything({ +applicationJson.postAnything({ number: 1, string: 'f"oo', arr: [1, 2, 3], diff --git a/packages/httpsnippet-client-api/test/__datasets__/auth-apikey-cookie/output.js b/packages/httpsnippet-client-api/test/__datasets__/auth-apikey-cookie/output.js index f938257a..83e45efd 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/auth-apikey-cookie/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/auth-apikey-cookie/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/auth-apikey-cookie'; +import authApikeyCookie from '@api/auth-apikey-cookie'; -sdk.auth('buster'); -sdk.postAnythingApikey() +authApikeyCookie.auth('buster'); +authApikeyCookie.postAnythingApikey() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/auth-apikey-header/output.js b/packages/httpsnippet-client-api/test/__datasets__/auth-apikey-header/output.js index 1afaf5fc..daf06061 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/auth-apikey-header/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/auth-apikey-header/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/auth-apikey-header'; +import authApikeyHeader from '@api/auth-apikey-header'; -sdk.auth('a5a220e'); -sdk.putAnythingApikey() +authApikeyHeader.auth('a5a220e'); +authApikeyHeader.putAnythingApikey() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/auth-basic-full/output.js b/packages/httpsnippet-client-api/test/__datasets__/auth-basic-full/output.js index 2b506751..ce14555c 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/auth-basic-full/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/auth-basic-full/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/auth-basic-full'; +import authBasicFull from '@api/auth-basic-full'; -sdk.auth('buster', 'pug'); -sdk.getAPISpecification({perPage: '10', page: '1'}) +authBasicFull.auth('buster', 'pug'); +authBasicFull.getAPISpecification({perPage: '10', page: '1'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/auth-basic-password-only/output.js b/packages/httpsnippet-client-api/test/__datasets__/auth-basic-password-only/output.js index 4c88d548..0f19d760 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/auth-basic-password-only/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/auth-basic-password-only/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/auth-basic-password-only'; +import authBasicPasswordOnly from '@api/auth-basic-password-only'; -sdk.auth('', 'pug'); -sdk.getAPISpecification({perPage: '10', page: '1'}) +authBasicPasswordOnly.auth('', 'pug'); +authBasicPasswordOnly.getAPISpecification({perPage: '10', page: '1'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/auth-basic-username-only/output.js b/packages/httpsnippet-client-api/test/__datasets__/auth-basic-username-only/output.js index 2b5085f8..38119319 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/auth-basic-username-only/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/auth-basic-username-only/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/auth-basic-username-only'; +import authBasicUsernameOnly from '@api/auth-basic-username-only'; -sdk.auth('buster'); -sdk.getAPISpecification({perPage: '10', page: '1'}) +authBasicUsernameOnly.auth('buster'); +authBasicUsernameOnly.getAPISpecification({perPage: '10', page: '1'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/auth-bearer/output.js b/packages/httpsnippet-client-api/test/__datasets__/auth-bearer/output.js index 55431d7e..dd044716 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/auth-bearer/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/auth-bearer/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/auth-bearer'; +import authBearer from '@api/auth-bearer'; -sdk.auth('myBearerToken'); -sdk.postAnythingBearer() +authBearer.auth('myBearerToken'); +authBearer.postAnythingBearer() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/auth-query/output.js b/packages/httpsnippet-client-api/test/__datasets__/auth-query/output.js index 339c4dd9..27929f1e 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/auth-query/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/auth-query/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/auth-query'; +import authQuery from '@api/auth-query'; -sdk.auth('a5a220e'); -sdk.getAnythingApikey() +authQuery.auth('a5a220e'); +authQuery.getAnythingApikey() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/cookies/output.js b/packages/httpsnippet-client-api/test/__datasets__/cookies/output.js index cc1c1a0f..f4a7039b 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/cookies/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/cookies/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/cookies'; +import cookies from '@api/cookies'; -sdk.postAnything({bar: 'baz', foo: 'bar'}) +cookies.postAnything({bar: 'baz', foo: 'bar'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/full-many-query-params/output.js b/packages/httpsnippet-client-api/test/__datasets__/full-many-query-params/output.js index df4693be..8b76290c 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/full-many-query-params/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/full-many-query-params/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/full-many-query-params'; +import fullManyQueryParams from '@api/full-many-query-params'; -sdk.postAnything({ +fullManyQueryParams.postAnything({ foo: 'bar', foo2: 'bar2', foo3: 'bar3', diff --git a/packages/httpsnippet-client-api/test/__datasets__/full/output.js b/packages/httpsnippet-client-api/test/__datasets__/full/output.js index 237ac5d6..0ea69a0a 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/full/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/full/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/full'; +import full from '@api/full'; -sdk.postAnything({foo: 'bar'}, { +full.postAnything({foo: 'bar'}, { foo: ['bar', 'baz'], baz: 'abc', key: 'value', diff --git a/packages/httpsnippet-client-api/test/__datasets__/headers/output.js b/packages/httpsnippet-client-api/test/__datasets__/headers/output.js index 23ba51b9..8a265370 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/headers/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/headers/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/headers'; +import headers from '@api/headers'; -sdk.getAnything({'x-foo': 'Bar', 'x-bar': 'foo', reqKey: 'baz'}) +headers.getAnything({'x-foo': 'Bar', 'x-bar': 'foo', reqKey: 'baz'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/http-insecure/output.js b/packages/httpsnippet-client-api/test/__datasets__/http-insecure/output.js index f6a9193f..0a45bee8 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/http-insecure/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/http-insecure/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/http-insecure'; +import httpInsecure from '@api/http-insecure'; -sdk.getAnything() +httpInsecure.getAnything() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/issue-128/output.js b/packages/httpsnippet-client-api/test/__datasets__/issue-128/output.js index 20b78249..f5495d20 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/issue-128/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/issue-128/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/issue-128'; +import issue128 from '@api/issue-128'; -sdk.auth('authKey\'With\'Apostrophes'); -sdk.getItem() +issue128.auth('authKey\'With\'Apostrophes'); +issue128.getItem() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/issue-76/output.js b/packages/httpsnippet-client-api/test/__datasets__/issue-76/output.js index 5e5eaf34..4696592c 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/issue-76/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/issue-76/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/issue-76'; +import issue76 from '@api/issue-76'; -sdk.auth('a5a220e'); -sdk.getPetFindbystatus({status: 'available'}) +issue76.auth('a5a220e'); +issue76.getPetFindbystatus({status: 'available'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/issue-78-operationid/output.js b/packages/httpsnippet-client-api/test/__datasets__/issue-78-operationid/output.js index ed821354..6f253692 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/issue-78-operationid/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/issue-78-operationid/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/issue-78-operationid'; +import issue78Operationid from '@api/issue-78-operationid'; -sdk.getOrder({orderId: '1234'}) +issue78Operationid.getOrder({orderId: '1234'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/issue-78/output.js b/packages/httpsnippet-client-api/test/__datasets__/issue-78/output.js index b8ef3eeb..69b68104 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/issue-78/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/issue-78/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/issue-78'; +import issue78 from '@api/issue-78'; -sdk.getStoreOrderOrderidTrackingTrackingid({orderId: '1234', trackingId: '5678'}) +issue78.getStoreOrderOrderidTrackingTrackingid({orderId: '1234', trackingId: '5678'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/jsonObj-multiline/output.js b/packages/httpsnippet-client-api/test/__datasets__/jsonObj-multiline/output.js index 9d8f611a..aa275a4a 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/jsonObj-multiline/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/jsonObj-multiline/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/jsonObj-multiline'; +import jsonObjMultiline from '@api/jsonObj-multiline'; -sdk.postAnything({foo: 'bar'}) +jsonObjMultiline.postAnything({foo: 'bar'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/jsonObj-null-value/output.js b/packages/httpsnippet-client-api/test/__datasets__/jsonObj-null-value/output.js index b6176366..7f6090f7 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/jsonObj-null-value/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/jsonObj-null-value/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/jsonObj-null-value'; +import jsonObjNullValue from '@api/jsonObj-null-value'; -sdk.postAnything({foo: null}) +jsonObjNullValue.postAnything({foo: null}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/multipart-data/output.js b/packages/httpsnippet-client-api/test/__datasets__/multipart-data/output.js index 3b8b07d3..74bc97e8 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/multipart-data/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/multipart-data/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/multipart-data'; +import multipartData from '@api/multipart-data'; -sdk.postAnything({foo: 'test/__fixtures__/files/hello.txt'}) +multipartData.postAnything({foo: 'test/__fixtures__/files/hello.txt'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/multipart-file/output.js b/packages/httpsnippet-client-api/test/__datasets__/multipart-file/output.js index 06aa72cd..38a1bccd 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/multipart-file/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/multipart-file/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/multipart-file'; +import multipartFile from '@api/multipart-file'; -sdk.postAnything({foo: 'test/__fixtures__/files/hello.txt'}) +multipartFile.postAnything({foo: 'test/__fixtures__/files/hello.txt'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/multipart-form-data-no-params/output.js b/packages/httpsnippet-client-api/test/__datasets__/multipart-form-data-no-params/output.js index c5ce0800..d42e5e8a 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/multipart-form-data-no-params/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/multipart-form-data-no-params/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/multipart-form-data-no-params'; +import multipartFormDataNoParams from '@api/multipart-form-data-no-params'; -sdk.postAnything() +multipartFormDataNoParams.postAnything() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/multipart-form-data/output.js b/packages/httpsnippet-client-api/test/__datasets__/multipart-form-data/output.js index 2893545a..e5221937 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/multipart-form-data/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/multipart-form-data/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/multipart-form-data'; +import multipartFormData from '@api/multipart-form-data'; -sdk.postAnything({foo: 'bar'}) +multipartFormData.postAnything({foo: 'bar'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/operationid-non-alphanumerical/output.js b/packages/httpsnippet-client-api/test/__datasets__/operationid-non-alphanumerical/output.js index 84ce7adb..992985fb 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/operationid-non-alphanumerical/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/operationid-non-alphanumerical/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/operationid-non-alphanumerical'; +import operationidNonAlphanumerical from '@api/operationid-non-alphanumerical'; -sdk.auth('123'); -sdk.findPetsByStatus({status: 'available'}) +operationidNonAlphanumerical.auth('123'); +operationidNonAlphanumerical.findPetsByStatus({status: 'available'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/operationid-with-underscores/output.js b/packages/httpsnippet-client-api/test/__datasets__/operationid-with-underscores/output.js index 52b3eba1..450b64ec 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/operationid-with-underscores/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/operationid-with-underscores/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/operationid-with-underscores'; +import operationidWithUnderscores from '@api/operationid-with-underscores'; -sdk.anything_Operation() +operationidWithUnderscores.anything_Operation() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/parameter-special-characters/output.js b/packages/httpsnippet-client-api/test/__datasets__/parameter-special-characters/output.js index 75e3373f..eb94a97c 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/parameter-special-characters/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/parameter-special-characters/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/parameter-special-characters'; +import parameterSpecialCharacters from '@api/parameter-special-characters'; -sdk.getAppIdNumInstalls_reportV5({'app-id': '1234', num: '5678'}) +parameterSpecialCharacters.getAppIdNumInstalls_reportV5({'app-id': '1234', num: '5678'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/petstore/output.js b/packages/httpsnippet-client-api/test/__datasets__/petstore/output.js index 0e2bb468..d4711704 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/petstore/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/petstore/output.js @@ -1,6 +1,6 @@ -import sdk from '@api/petstore'; +import petstore from '@api/petstore'; -sdk.auth('123'); -sdk.findPetsByStatus({status: 'available', accept: 'application/xml'}) +petstore.auth('123'); +petstore.findPetsByStatus({status: 'available', accept: 'application/xml'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/query/output.js b/packages/httpsnippet-client-api/test/__datasets__/query/output.js index 50d22332..002a927c 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/query/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/query/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/query'; +import query from '@api/query'; -sdk.getAnything({foo: ['bar', 'baz'], baz: 'abc', key: 'value'}) +query.getAnything({foo: ['bar', 'baz'], baz: 'abc', key: 'value'}) .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/short/output.js b/packages/httpsnippet-client-api/test/__datasets__/short/output.js index e0cfb906..b873ffe1 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/short/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/short/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/short'; +import short from '@api/short'; -sdk.getAnything() +short.getAnything() .then(({ data }) => console.log(data)) .catch(err => console.error(err)); diff --git a/packages/httpsnippet-client-api/test/__datasets__/text-plain/output.js b/packages/httpsnippet-client-api/test/__datasets__/text-plain/output.js index 8c51d966..456099c6 100644 --- a/packages/httpsnippet-client-api/test/__datasets__/text-plain/output.js +++ b/packages/httpsnippet-client-api/test/__datasets__/text-plain/output.js @@ -1,5 +1,5 @@ -import sdk from '@api/text-plain'; +import textPlain from '@api/text-plain'; -sdk.postAnything('Hello World') +textPlain.postAnything('Hello World') .then(({ data }) => console.log(data)) .catch(err => console.error(err));