Skip to content

Commit

Permalink
Add yml file extension support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Jun 19, 2023
1 parent cfe0780 commit e614fdf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Plugins/OpenAPIGenerator/plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ struct SwiftOpenAPIGeneratorPlugin {
"Incompatible target called '\(targetName)'. Only Swift source targets can be used with the Swift OpenAPI generator plugin."
case .noConfigFound(let targetName):
return
"No config found in the target named '\(targetName)'. Add a file called 'openapi-generator-config.yaml' to the target's source directory. See documentation for details."
"No config found in the target named '\(targetName)'. Add a file called 'openapi-generator-config.yaml' or 'openapi-generator-config.yml' to the target's source directory. See documentation for details."
case .noDocumentFound(let targetName):
return
"No OpenAPI document found in the target named '\(targetName)'. Add a file called 'openapi.yaml' or 'openapi.json' (can also be a symlink) to the target's source directory. See documentation for details."
"No OpenAPI document found in the target named '\(targetName)'. Add a file called 'openapi.yaml', 'openapi.yml' or 'openapi.json' (can also be a symlink) to the target's source directory. See documentation for details."
}
}

Expand All @@ -47,14 +47,14 @@ struct SwiftOpenAPIGeneratorPlugin {
targetName: String
) throws -> [Command] {
let inputFiles = sourceFiles
guard let config = inputFiles.first(where: { $0.path.lastComponent == "openapi-generator-config.yaml" })?.path
guard let config = inputFiles.first(where: { $0.path.lastComponent == "openapi-generator-config.yaml" || $0.path.lastComponent == "openapi-generator-config.yml" })?.path
else {
throw Error.noConfigFound(targetName: targetName)
}
guard
let doc = inputFiles.first(where: {
switch $0.path.lastComponent {
case "openapi.yaml", "openapi.json":
case "openapi.yaml", "openapi.yml", "openapi.json":
return true
default:
return false
Expand Down

0 comments on commit e614fdf

Please sign in to comment.