Class: SpecForge::CLI::Docs
- Includes:
- Docs::Generate
- Defined in:
- lib/spec_forge/cli/docs.rb,
lib/spec_forge/cli/docs/generate.rb
Overview
Command for generating OpenAPI documentation from SpecForge tests
Runs tests and extracts endpoint data to create OpenAPI specifications. Uses intelligent caching to avoid unnecessary test re-execution when specs haven't changed.
Defined Under Namespace
Modules: Generate
Constant Summary collapse
- VALID_FORMATS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Valid file formats for documentation output
Supported formats include YAML variants (yml, yaml) and JSON. Used for validation when users specify the --format option.
%w[yml yaml json].freeze
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
-
#call ⇒ void
Generates OpenAPI documentation from tests.
Methods inherited from Command
aliases, example, #initialize, option, register
Methods included from Actions
Constructor Details
This class inherits a constructor from SpecForge::CLI::Command
Instance Method Details
#call ⇒ void
This method returns an undefined value.
Generates OpenAPI documentation from tests
Runs all SpecForge tests and creates OpenAPI specifications from the successful test results. This is the main entry point for the docs workflow.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/spec_forge/cli/docs.rb', line 73 def call # spec_forge/openapi/generated generated_path = SpecForge.openapi_path.join("generated") actions.empty_directory(generated_path, verbose: false) actions.empty_directory(generated_path.join(".cache"), verbose: false) file_path = generate_documentation puts <<~STRING ======================================== 🎉 Success! ======================================== Your OpenAPI specification is valid and ready to use. Output written to: #{file_path.relative_path_from(SpecForge.forge_path)} STRING rescue NoBlueprintsError => e puts e. end |