Add support for configurable comments in generated files by simonjbeaumont · Pull Request #773 · apple/swift-openapi-generator (original) (raw)
Users want the ability to add custom comments to generated files. One concrete use case is adding directives like swift-format-ignore-file
and swiftlint:disable all
to prevent these tools from processing generated code.
Users can now configure additional comments to be added to generated files using either the config file or a command line option.
% swift run swift-openapi-generator generate openapi-documents/petstore.yaml
--mode types
--output-directory test-output-cli
--additional-file-comment "hello world"
--additional-file-comment "testing, testing, 1, 2, 3"
Build of product 'swift-openapi-generator' complete! (3.27s)
Swift OpenAPI Generator is running with the following configuration:
- OpenAPI document path: /Users/Si/work/code/swift-openapi-workspace/packages/swift-openapi-generator/openapi-documents/petstore.yaml
- Configuration path:
- Generator modes: types
- Access modifier: internal
- Naming strategy: defensive
- Name overrides:
- Feature flags:
- Output file names: Types.swift
- Output directory: /Users/Si/work/code/swift-openapi-workspace/packages/swift-openapi-generator/test-output-cli
- Diagnostics output path: <none - logs to stderr>
- Current directory: /Users/Si/work/code/swift-openapi-workspace/packages/swift-openapi-generator
- Plugin source:
- Is dry run: false
- Additional imports:
- Additional file comments: hello world, testing, testing, 1, 2, 3 Writing data to file Types.swift...
% head -5 test-output-cli/Types.swift // Generated by swift-openapi-generator, do not modify. // hello world // testing, testing, 1, 2, 3 @_spi(Generated) import OpenAPIRuntime