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
16 changes: 11 additions & 5 deletions dist/src/tools/create_collection.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { z } from 'zod';
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
export const method = 'create-collection';
export const description = 'Creates a collection using the [Postman Collection v2.1.0 schema format](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n\n**Note:**\n\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in your "My Workspace" workspace.\n- For a complete list of available property values for this endpoint, use the following references available in the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html):\n - \\`info\\` object — Refer to the **Information** entry.\n - \\`item\\` object — Refer to the **Items** entry.\n- For all other possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n';
export const description = 'Creates a collection using the [Postman Collection v2.1.0 schema format](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n\n**Note:**\n\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in the oldest personal Internal workspace you own.\n- For a complete list of available property values for this endpoint, use the following references available in the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html):\n - \\`info\\` object — Refer to the **Information** entry.\n - \\`item\\` object — Refer to the **Items** entry.\n- For all other possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n';
export const parameters = z.object({
workspace: z.string().describe("The workspace's ID.").optional(),
workspace: z.string().describe("The workspace's ID."),
collection: z
.object({
info: z
Expand Down Expand Up @@ -32,7 +32,10 @@ export const parameters = z.object({
.string()
.describe("The variable's description. Doesn't apply to collection-level variables.")
.optional(),
disabled: z.boolean().default(false),
disabled: z
.boolean()
.describe('If true, the variable is not enabled.')
.default(false),
})
.describe('Information about the variable.'))
.describe("A list of the collection's [variables](https://learning.postman.com/docs/sending-requests/variables/variables/). Make certain not to include sensitive information in variables.")
Expand Down Expand Up @@ -515,7 +518,10 @@ export const parameters = z.object({
.string()
.describe("The variable's description. Doesn't apply to collection-level variables.")
.optional(),
disabled: z.boolean().default(false),
disabled: z
.boolean()
.describe('If true, the variable is not enabled.')
.default(false),
})
.describe('Information about the variable.'))
.describe("A list of the collection's [variables](https://learning.postman.com/docs/sending-requests/variables/variables/). Make certain not to include sensitive information in variables.")
Expand Down Expand Up @@ -771,7 +777,7 @@ export const parameters = z.object({
.optional(),
});
export const annotations = {
title: 'Creates a collection using the [Postman Collection v2.1.0 schema format](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n\n**Note:**\n\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in your "My Workspace" workspace.\n- For a complete list of available property values for this endpoint, use the following references available in the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html):\n - \\`info\\` object — Refer to the **Information** entry.\n - \\`item\\` object — Refer to the **Items** entry.\n- For all other possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n',
title: 'Creates a collection using the [Postman Collection v2.1.0 schema format](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n\n**Note:**\n\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in the oldest personal Internal workspace you own.\n- For a complete list of available property values for this endpoint, use the following references available in the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html):\n - \\`info\\` object — Refer to the **Information** entry.\n - \\`item\\` object — Refer to the **Items** entry.\n- For all other possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n',
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
Expand Down
7 changes: 4 additions & 3 deletions dist/src/tools/create_environment.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { z } from 'zod';
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
export const method = 'create-environment';
export const description = 'Creates an environment.\n\n**Note:**\n\n- The request body size cannot exceed the maximum allowed size of 30MB.\n- If you receive an HTTP \\`411 Length Required\\` error response, manually pass the \\`Content-Length\\` header and its value in the request header.\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in your "My Workspace" workspace.\n';
export const description = 'Creates an environment.\n\n**Note:**\n\n- The request body size cannot exceed the maximum allowed size of 30MB.\n- If you receive an HTTP \\`411 Length Required\\` error response, manually pass the \\`Content-Length\\` header and its value in the request header.\n- If you do not include the \\`workspace\\` query parameter, the system creates the environment in the oldest personal Internal workspace you own.\n';
export const parameters = z.object({
workspace: z.string().describe("The workspace's ID.").optional(),
workspace: z.string().describe("The workspace's ID."),
environment: z
.object({
name: z.string().describe("The environment's name."),
Expand All @@ -17,10 +17,11 @@ export const parameters = z.object({
.describe("Information about the environment's variables.")
.optional(),
})
.describe('Information about the environment.')
.optional(),
});
export const annotations = {
title: 'Creates an environment.\n\n**Note:**\n\n- The request body size cannot exceed the maximum allowed size of 30MB.\n- If you receive an HTTP \\`411 Length Required\\` error response, manually pass the \\`Content-Length\\` header and its value in the request header.\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in your "My Workspace" workspace.\n',
title: 'Creates an environment.\n\n**Note:**\n\n- The request body size cannot exceed the maximum allowed size of 30MB.\n- If you receive an HTTP \\`411 Length Required\\` error response, manually pass the \\`Content-Length\\` header and its value in the request header.\n- If you do not include the \\`workspace\\` query parameter, the system creates the environment in the oldest personal Internal workspace you own.\n',
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
Expand Down
10 changes: 5 additions & 5 deletions dist/src/tools/create_mock.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { z } from 'zod';
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
export const method = 'create-mock';
export const description = 'Creates a mock server in a collection.\n\n**Note:**\n\n- If you do not include the \\`workspaceId\\` query parameter, the system creates the mock server in your [Personal\nworkspace](https://learning.postman.com/docs/collaborating-in-postman/using-workspaces/creating-workspaces/).\n- You cannot create mocks for collections added to an API definition.\n';
export const description = 'Creates a mock server in a collection.\n\n**Note:**\n\n- You cannot create mocks for collections added to an API definition.\n- If you do not include the \\`workspaceId\\` query parameter, the system creates the mock server in the oldest personal Internal workspace you own.\n';
export const parameters = z.object({
workspaceId: z.string().describe("The workspace's ID.").optional(),
workspace: z.string().describe("The workspace's ID."),
mock: z
.object({
collection: z.string().describe("The unique ID of the mock's associated collection."),
Expand All @@ -20,7 +20,7 @@ export const parameters = z.object({
.optional(),
});
export const annotations = {
title: 'Creates a mock server in a collection.\n\n**Note:**\n\n- If you do not include the \\`workspaceId\\` query parameter, the system creates the mock server in your [Personal\nworkspace](https://learning.postman.com/docs/collaborating-in-postman/using-workspaces/creating-workspaces/).\n- You cannot create mocks for collections added to an API definition.\n',
title: 'Creates a mock server in a collection.\n\n**Note:**\n\n- You cannot create mocks for collections added to an API definition.\n- If you do not include the \\`workspaceId\\` query parameter, the system creates the mock server in the oldest personal Internal workspace you own.\n',
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
Expand All @@ -29,8 +29,8 @@ export async function handler(params, extra) {
try {
const endpoint = `/mocks`;
const query = new URLSearchParams();
if (params.workspaceId !== undefined)
query.set('workspaceId', String(params.workspaceId));
if (params.workspace !== undefined)
query.set('workspace', String(params.workspace));
const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
const bodyPayload = {};
if (params.mock !== undefined)
Expand Down
7 changes: 4 additions & 3 deletions dist/src/tools/create_monitor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { z } from 'zod';
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
export const method = 'create-monitor';
export const description = 'Creates a monitor.\n\n**Note:**\n\n- You cannot create monitors for collections added to an API definition.\n- If you do not pass the \\`workspace\\` parameter, the monitor is created in your personal workspace.\n';
export const description = 'Creates a monitor.\n\n**Note:**\n\n- You cannot create monitors for collections added to an API definition.\n- If you do not pass the \\`workspace\\` query parameter, the system creates the monitor in the oldest personal Internal workspace you own.\n';
export const parameters = z.object({
workspace: z.string().describe("The workspace's ID.").optional(),
workspace: z.string().describe("The workspace's ID."),
monitor: z
.object({
name: z.string().describe("The monitor's name."),
Expand Down Expand Up @@ -106,10 +106,11 @@ export const parameters = z.object({
.describe("Information about the monitor's notification settings.")
.optional(),
})
.describe('Information about the monitor.')
.optional(),
});
export const annotations = {
title: 'Creates a monitor.\n\n**Note:**\n\n- You cannot create monitors for collections added to an API definition.\n- If you do not pass the \\`workspace\\` parameter, the monitor is created in your personal workspace.\n',
title: 'Creates a monitor.\n\n**Note:**\n\n- You cannot create monitors for collections added to an API definition.\n- If you do not pass the \\`workspace\\` query parameter, the system creates the monitor in the oldest personal Internal workspace you own.\n',
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
Expand Down
32 changes: 25 additions & 7 deletions dist/src/tools/create_spec.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
import { z } from 'zod';
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
export const method = 'create-spec';
export const description = "Creates an API specification in Postman's [Spec Hub](https://learning.postman.com/docs/design-apis/specifications/overview/).\n\n**Note:**\n- Postman supports OpenAPI 3.0 and AsyncAPI 2.0 specifications.\n- This endpoint does not yet support multiple files.\n";
export const description = "Creates an API specification in Postman's [Spec Hub](https://learning.postman.com/docs/design-apis/specifications/overview/). Specifications can be single or multi-file.\n\n**Note:**\n- Postman supports OpenAPI 3.0 and AsyncAPI 2.0 specifications.\n- If the file path contains a \\`/\\` (forward slash) character, then a folder is created. For example, if the path is the \\`components/schemas.json\\` value, then a \\`components\\` folder is created with the \\`schemas.json\\` file inside.\n- Multi-file specifications can only have one root file.\n- Files cannot exceed a maximum of 10 MB in size.\n";
export const parameters = z.object({
workspaceId: z.string().describe("The workspace's ID."),
name: z.string().describe("The specification's name."),
type: z.enum(['OPENAPI:3.0', 'ASYNCAPI:2.0']).describe("The specification's type."),
files: z
.array(z.object({
path: z
.string()
.describe("The file's path. Accepts the `index.json` or `index.yaml` value."),
content: z.string().describe("The file's stringified contents."),
.array(z.any().superRefine((x, ctx) => {
const schemas = [
z.object({
path: z.string().describe("The file's path. Accepts JSON or YAML files."),
content: z.string().describe("The file's stringified contents."),
type: z
.enum(['DEFAULT', 'ROOT'])
.describe('The type of file. This property is required when creating multi-file specifications:\n- `ROOT` — The file containing the full OpenAPI structure. This serves as the entry point for the API spec and references other (`DEFAULT`) spec files. Multi-file specs can only have one root file.\n- `DEFAULT` — A file referenced by the `ROOT` file.\n'),
}),
z.object({
path: z.string().describe("The file's path. Accepts JSON or YAML files."),
content: z.string().describe("The file's stringified contents."),
}),
];
const errors = schemas.reduce((errors, schema) => ((result) => (result.error ? [...errors, result.error] : errors))(schema.safeParse(x)), []);
if (schemas.length - errors.length !== 1) {
ctx.addIssue({
path: ctx.path,
code: 'invalid_union',
unionErrors: errors,
message: 'Invalid input: Should pass single schema',
});
}
}))
.describe("A list of the specification's files and their contents."),
});
export const annotations = {
title: "Creates an API specification in Postman's [Spec Hub](https://learning.postman.com/docs/design-apis/specifications/overview/).\n\n**Note:**\n- Postman supports OpenAPI 3.0 and AsyncAPI 2.0 specifications.\n- This endpoint does not yet support multiple files.\n",
title: "Creates an API specification in Postman's [Spec Hub](https://learning.postman.com/docs/design-apis/specifications/overview/). Specifications can be single or multi-file.\n\n**Note:**\n- Postman supports OpenAPI 3.0 and AsyncAPI 2.0 specifications.\n- If the file path contains a \\`/\\` (forward slash) character, then a folder is created. For example, if the path is the \\`components/schemas.json\\` value, then a \\`components\\` folder is created with the \\`schemas.json\\` file inside.\n- Multi-file specifications can only have one root file.\n- Files cannot exceed a maximum of 10 MB in size.\n",
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
Expand Down
47 changes: 47 additions & 0 deletions dist/src/tools/create_spec_file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { z } from 'zod';
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
export const method = 'create-spec-file';
export const description = 'Creates an API specification file.\n\n**Note:**\n\n- If the file path contains a \\`/\\` (forward slash) character, then a folder is created. For example, if the path is the \\`components/schemas.json\\` value, then a \\`components\\` folder is created with the \\`schemas.json\\` file inside.\n- Creating a spec file assigns it the \\`DEFAULT\\` file type.\n- Multi-file specifications can only have one root file.\n- Files cannot exceed a maximum of 10 MB in size.\n';
export const parameters = z.object({
specId: z.string().describe("The spec's ID."),
path: z.string().describe("The file's path. Accepts JSON or YAML files."),
content: z.string().describe("The file's stringified contents."),
});
export const annotations = {
title: 'Creates an API specification file.\n\n**Note:**\n\n- If the file path contains a \\`/\\` (forward slash) character, then a folder is created. For example, if the path is the \\`components/schemas.json\\` value, then a \\`components\\` folder is created with the \\`schemas.json\\` file inside.\n- Creating a spec file assigns it the \\`DEFAULT\\` file type.\n- Multi-file specifications can only have one root file.\n- Files cannot exceed a maximum of 10 MB in size.\n',
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
};
export async function handler(params, extra) {
try {
const endpoint = `/specs/${params.specId}/files`;
const query = new URLSearchParams();
const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
const bodyPayload = {};
if (params.path !== undefined)
bodyPayload.path = params.path;
if (params.content !== undefined)
bodyPayload.content = params.content;
const result = await fetchPostmanAPI(url, {
method: 'POST',
body: JSON.stringify(bodyPayload),
contentType: ContentType.Json,
apiKey: extra.apiKey,
headers: extra.headers,
});
return {
content: [
{
type: 'text',
text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`,
},
],
};
}
catch (e) {
return {
content: [{ type: 'text', text: `Failed: ${e.message}` }],
};
}
}
39 changes: 39 additions & 0 deletions dist/src/tools/delete_spec_file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { z } from 'zod';
import { fetchPostmanAPI } from '../clients/postman.js';
export const method = 'delete-spec-file';
export const description = 'Deletes a file in an API specification. On success, this returns an HTTP \\`204 No Content\\` response.';
export const parameters = z.object({
specId: z.string().describe("The spec's ID."),
filePath: z.string().describe('The path to the file.'),
});
export const annotations = {
title: 'Deletes a file in an API specification. On success, this returns an HTTP \\`204 No Content\\` response.',
readOnlyHint: false,
destructiveHint: true,
idempotentHint: true,
};
export async function handler(params, extra) {
try {
const endpoint = `/specs/${params.specId}/files/${params.filePath}`;
const query = new URLSearchParams();
const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
const result = await fetchPostmanAPI(url, {
method: 'DELETE',
apiKey: extra.apiKey,
headers: extra.headers,
});
return {
content: [
{
type: 'text',
text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`,
},
],
};
}
catch (e) {
return {
content: [{ type: 'text', text: `Failed: ${e.message}` }],
};
}
}
Loading
Loading