Skip to content
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

Added ability to prepend a basePath to typescript-redux-query generators #6943

Merged
merged 2 commits into from
Aug 11, 2020
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 @@ -157,7 +157,7 @@ function {{nickname}}Raw<T>({{#allParams.0}}requestParameters: {{operationIdCame
{{/isListContainer}}
{{/formParams}}
const config: QueryConfig<T> = {
url: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}},
url: `${runtime.Configuration.basePath}{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}},
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { Meta, OptimisticUpdate, QueryKey, QueryOptions, Rollback, TransformStra

export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");

export const Configuration = {
basePath: '', // This is the value that will be prepended to all endpoints. For compatibility with
// previous versions, the default is an empty string. Other generators typically use
// BASE_PATH as the default.
};

export interface TypedQueryConfig<TState, TBody> {
force?: boolean;
meta?: Meta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function addPetRaw<T>(requestParameters: AddPetRequest, requestConfig: runtime.T

meta.authType = ['oauth', ["write:pets", "read:pets"]];
const config: QueryConfig<T> = {
url: `/pet`,
url: `${runtime.Configuration.basePath}/pet`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -132,7 +132,7 @@ function deletePetRaw<T>(requestParameters: DeletePetRequest, requestConfig: run

meta.authType = ['oauth', ["write:pets", "read:pets"]];
const config: QueryConfig<T> = {
url: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
url: `${runtime.Configuration.basePath}/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -185,7 +185,7 @@ function findPetsByStatusRaw<T>(requestParameters: FindPetsByStatusRequest, requ

meta.authType = ['oauth', ["write:pets", "read:pets"]];
const config: QueryConfig<T> = {
url: `/pet/findByStatus`,
url: `${runtime.Configuration.basePath}/pet/findByStatus`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -240,7 +240,7 @@ function findPetsByTagsRaw<T>(requestParameters: FindPetsByTagsRequest, requestC

meta.authType = ['oauth', ["write:pets", "read:pets"]];
const config: QueryConfig<T> = {
url: `/pet/findByTags`,
url: `${runtime.Configuration.basePath}/pet/findByTags`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -289,7 +289,7 @@ function getPetByIdRaw<T>(requestParameters: GetPetByIdRequest, requestConfig: r

meta.authType = ['api_key', 'header'];
const config: QueryConfig<T> = {
url: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
url: `${runtime.Configuration.basePath}/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -339,7 +339,7 @@ function updatePetRaw<T>(requestParameters: UpdatePetRequest, requestConfig: run

meta.authType = ['oauth', ["write:pets", "read:pets"]];
const config: QueryConfig<T> = {
url: `/pet`,
url: `${runtime.Configuration.basePath}/pet`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -394,7 +394,7 @@ function updatePetWithFormRaw<T>(requestParameters: UpdatePetWithFormRequest, re
}

const config: QueryConfig<T> = {
url: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
url: `${runtime.Configuration.basePath}/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -449,7 +449,7 @@ function uploadFileRaw<T>(requestParameters: UploadFileRequest, requestConfig: r
}

const config: QueryConfig<T> = {
url: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
url: `${runtime.Configuration.basePath}/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function deleteOrderRaw<T>(requestParameters: DeleteOrderRequest, requestConfig:
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
url: `${runtime.Configuration.basePath}/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -96,7 +96,7 @@ function getInventoryRaw<T>( requestConfig: runtime.TypedQueryConfig<T, { [key:

meta.authType = ['api_key', 'header'];
const config: QueryConfig<T> = {
url: `/store/inventory`,
url: `${runtime.Configuration.basePath}/store/inventory`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -143,7 +143,7 @@ function getOrderByIdRaw<T>(requestParameters: GetOrderByIdRequest, requestConfi
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
url: `${runtime.Configuration.basePath}/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))),
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -192,7 +192,7 @@ function placeOrderRaw<T>(requestParameters: PlaceOrderRequest, requestConfig: r
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/store/order`,
url: `${runtime.Configuration.basePath}/store/order`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function createUserRaw<T>(requestParameters: CreateUserRequest, requestConfig: r
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/user`,
url: `${runtime.Configuration.basePath}/user`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -120,7 +120,7 @@ function createUsersWithArrayInputRaw<T>(requestParameters: CreateUsersWithArray
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/user/createWithArray`,
url: `${runtime.Configuration.basePath}/user/createWithArray`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -167,7 +167,7 @@ function createUsersWithListInputRaw<T>(requestParameters: CreateUsersWithListIn
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/user/createWithList`,
url: `${runtime.Configuration.basePath}/user/createWithList`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -213,7 +213,7 @@ function deleteUserRaw<T>(requestParameters: DeleteUserRequest, requestConfig: r
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
url: `${runtime.Configuration.basePath}/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -259,7 +259,7 @@ function getUserByNameRaw<T>(requestParameters: GetUserByNameRequest, requestCon
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
url: `${runtime.Configuration.basePath}/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -320,7 +320,7 @@ function loginUserRaw<T>(requestParameters: LoginUserRequest, requestConfig: run
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/user/login`,
url: `${runtime.Configuration.basePath}/user/login`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -362,7 +362,7 @@ function logoutUserRaw<T>( requestConfig: runtime.TypedQueryConfig<T, void> = {}
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/user/logout`,
url: `${runtime.Configuration.basePath}/user/logout`,
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down Expand Up @@ -414,7 +414,7 @@ function updateUserRaw<T>(requestParameters: UpdateUserRequest, requestConfig: r
const { meta = {} } = requestConfig;

const config: QueryConfig<T> = {
url: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
url: `${runtime.Configuration.basePath}/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))),
meta,
update: requestConfig.update,
queryKey: requestConfig.queryKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import { Meta, OptimisticUpdate, QueryKey, QueryOptions, Rollback, TransformStra

export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, "");

export const Configuration = {
basePath: '', // This is the value that will be prepended to all endpoints. For compatibility with
// previous versions, the default is an empty string. Other generators typically use
// BASE_PATH as the default.
};

export interface TypedQueryConfig<TState, TBody> {
force?: boolean;
meta?: Meta;
Expand Down