Core concepts

Configuration

All settings live in your config/autodoc.php file. This page is a reference of the general options; some groups have their own pages: workspaces, UI settings, TypeScript export and debugging.

API information

'api' => [
    'title' => $_ENV['APP_NAME'] ?? '',
    'version' => $_ENV['APP_VERSION'] ?? '',
    'domain' => $_ENV['APP_URL'] ?? '',
    'description' => '',
],

Included in the info and servers blocks of the exported OpenAPI schema.

Schema generation

  • openapi_export_dir - directory where the generated OpenAPI 3.1.0 JSON files are saved. Must exist and be writable.
  • route_loader - class used to load routes, must extend AutoDoc\AbstractRouteLoader. Set automatically in Laravel projects; see Installation for manual setup.
  • extensions - list of your custom extension class names.
  • use_cache - when enabled, the generated schema file is reused instead of being regenerated on each request.
  • memory_limit - PHP memory limit applied during schema generation, e.g. '2G'.
  • max_depth - maximum depth of nested type resolution. Increasing it allows deeper analysis of your codebase at the cost of speed.

OpenAPI output

'openapi' => [
    'show_values_for_scalar_types' => true,
    'use_pattern_for_numeric_strings' => false,
    'json_pretty_print' => false,
],
  • show_values_for_scalar_types - attempt to read possible values of returned scalar types and render them as const/enum. Not all possible values are guaranteed to be detected, so you may want to disable this in some projects.
  • use_pattern_for_numeric_strings - use pattern instead of format for numeric string types.
  • json_pretty_print - pretty print the exported JSON files.

Enums

'enum' => [
    'autodetect_components' => true,
    'remove_namespace' => true,
    'remove_description' => false,
    'create_links' => true,
    'show_allowed_values' => true,
    'generate_description_from_cases' => true,
],
  • autodetect_components - export all referenced enums as OpenAPI schema components. When disabled, only enums listed in the schemas option are exported.
  • remove_namespace - strip the namespace from exported enum names.
  • remove_description - ignore the enum's PHPDoc description.
  • create_links - link enum types to their schema components in descriptions.
  • show_allowed_values - list allowed values on enum-typed fields.
  • generate_description_from_cases - OpenAPI 3.1 has no per-case descriptions, so autodoc can generate an HTML description for the whole enum from its cases.

Type resolution

  • classes.remove_description - ignore class PHPDoc descriptions.
  • arrays.resolve_partial_shapes - resolve arrays as shapes when at least one key is known. When disabled, arrays only become shapes if all keys are known.
  • arrays.merge_shapes_in_type_unions and objects.merge_shapes_in_type_unions - merge array/object shapes appearing in type unions into one shape instead of rendering variants. A key present in only some variants becomes optional.
  • arrays.remove_scalar_type_values_when_merging_with_unknown_types - drop detected scalar values when a known type is merged with an unknown one.
  • intersections.render_empty_as_unknown - an impossible (empty) intersection renders as unknown instead of its literal empty form (OpenAPI { "enum": [] }, TypeScript never).

Debug

'debug' => [
    'enabled' => false,
    'ignore_dynamic_method_errors' => true,
    'ignore_unknown_method_errors_in_traits' => true,
],

By default analysis errors are silently ignored. See the Debugging section for details and tooling.

Laravel options

Available in Laravel projects under the laravel key:

  • url - docs page URL, /api-docs by default. Set to null to disable the package's documentation routes.
  • middleware - middleware applied to the docs routes, ['web'] by default.
  • autoload_builtin_extensions - load all built-in autodoc-laravel extensions. Enabled by default; disable only if you want to cherry-pick extensions yourself.
  • generate_descriptions_from_validation_rules and format_generated_descriptions - see Request validation.
  • abandon_query_builder_parsing_on_unknown_methods - see Query builder.
  • offline_mode - analyze without a database connection, see Eloquent models.
Previous
TypeScript