Skip to content

feat: apify actor generate-schema — AI generates INPUT_SCHEMA.json from existing Actor code #1441

Description

@kuntal1461

Problem

INPUT_SCHEMA.json is the most tedious part of publishing an Apify Actor. Developers typically:

  1. Write their Actor code with hardcoded or process.env-style inputs
  2. Manually inspect the code to figure out what inputs exist
  3. Hand-write INPUT_SCHEMA.json from scratch, often getting field types or required flags wrong
  4. Iterate because apify validate-schema or the platform build rejects it

This friction prevents many Actors from ever getting published with a proper schema.

Proposal

Add a new command that reads your Actor code and generates a draft INPUT_SCHEMA.json:

apify actor generate-schema

What it does

  1. Reads src/main.js (or main.py, src/main.ts, etc.) from the current Actor directory
  2. Extracts input references: input.url, Actor.getInput(), process.env.APIFY_*, argparse args, etc.
  3. Sends the relevant code snippets to an LLM with a schema generation prompt
  4. Writes a draft .actor/INPUT_SCHEMA.json
  5. Runs apify validate-schema on the result and reports any issues

Example

$ apify actor generate-schema

Reading src/main.js...
Found input references:
  input.startUrl    (string, used in fetch call)
  input.maxPages    (number, default 10)
  input.proxyConfig (object, passed to ProxyConfiguration)

Generating INPUT_SCHEMA.json...
  ✓ Written to .actor/INPUT_SCHEMA.json

Validating...
  ✓ Schema is valid

Review .actor/INPUT_SCHEMA.json and adjust descriptions before pushing.

Generated schema (example)

{
  "title": "My Actor",
  "description": "Auto-generated schema — review before publishing",
  "type": "object",
  "schemaVersion": 1,
  "properties": {
    "startUrl": {
      "title": "Start URL",
      "type": "string",
      "description": "The URL to start scraping from",
      "editor": "textfield"
    },
    "maxPages": {
      "title": "Max pages",
      "type": "integer",
      "description": "Maximum number of pages to scrape",
      "default": 10
    }
  },
  "required": ["startUrl"]
}

Why it matters

Open questions

  • Which LLM / API to call (Apify-hosted vs user brings API key)?
  • Support for Python (Actor.get_input(), typer, argparse)?
  • Should it update an existing schema or only create from scratch?

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-buildersIssues owned by the Builders team.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions