Skip to content

Commit

Permalink
docs: add server variables to demo
Browse files Browse the repository at this point in the history
ref #543
  • Loading branch information
Xiphe committed Feb 23, 2024
1 parent d73768f commit 48bc5d0
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 6 deletions.
10 changes: 9 additions & 1 deletion demo/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
const oazapfts = Oazapfts.runtime(defaults);
export const servers = {
server1: "https://petstore.swagger.io/v2",
server2: "http://petstore.swagger.io/v2",
server2: ({
protocol = "https",
stage = "staging",
version = "v1",
}: {
protocol: "http" | "https";
stage: "test" | "staging" | "production";
version: "v1" | "v2";
}) => `${protocol}://${stage}.petstore.example.org/${version}`,
};
export type Category = {
id?: number;
Expand Down
10 changes: 9 additions & 1 deletion demo/enumApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
const oazapfts = Oazapfts.runtime(defaults);
export const servers = {
server1: "https://petstore.swagger.io/v2",
server2: "http://petstore.swagger.io/v2",
server2: ({
protocol = "https",
stage = "staging",
version = "v1",
}: {
protocol: "http" | "https";
stage: "test" | "staging" | "production";
version: "v1" | "v2";
}) => `${protocol}://${stage}.petstore.example.org/${version}`,
};
export type Category = {
id?: number;
Expand Down
10 changes: 9 additions & 1 deletion demo/mergedReadWriteApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
const oazapfts = Oazapfts.runtime(defaults);
export const servers = {
server1: "https://petstore.swagger.io/v2",
server2: "http://petstore.swagger.io/v2",
server2: ({
protocol = "https",
stage = "staging",
version = "v1",
}: {
protocol: "http" | "https";
stage: "test" | "staging" | "production";
version: "v1" | "v2";
}) => `${protocol}://${stage}.petstore.example.org/${version}`,
};
export type Category = {
id?: number;
Expand Down
10 changes: 9 additions & 1 deletion demo/objectStyleArgument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
const oazapfts = Oazapfts.runtime(defaults);
export const servers = {
server1: "https://petstore.swagger.io/v2",
server2: "http://petstore.swagger.io/v2",
server2: ({
protocol = "https",
stage = "staging",
version = "v1",
}: {
protocol: "http" | "https";
stage: "test" | "staging" | "production";
version: "v1" | "v2";
}) => `${protocol}://${stage}.petstore.example.org/${version}`,
};
export type Category = {
id?: number;
Expand Down
10 changes: 9 additions & 1 deletion demo/optimisticApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
const oazapfts = Oazapfts.runtime(defaults);
export const servers = {
server1: "https://petstore.swagger.io/v2",
server2: "http://petstore.swagger.io/v2",
server2: ({
protocol = "https",
stage = "staging",
version = "v1",
}: {
protocol: "http" | "https";
stage: "test" | "staging" | "production";
version: "v1" | "v2";
}) => `${protocol}://${stage}.petstore.example.org/${version}`,
};
export type Category = {
id?: number;
Expand Down
16 changes: 15 additions & 1 deletion demo/petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,21 @@
"url": "https://petstore.swagger.io/v2"
},
{
"url": "http://petstore.swagger.io/v2"
"url": "{protocol}://{stage}.petstore.example.org/{version}",
"variables": {
"protocol": {
"enum": ["http", "https"],
"default": "https"
},
"stage": {
"enum": ["test", "staging", "production"],
"default": "staging"
},
"version": {
"enum": ["v1", "v2"],
"default": "v1"
}
}
}
],
"tags": [
Expand Down

0 comments on commit 48bc5d0

Please sign in to comment.