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:

% 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