Commit a46e0308 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'fix/openapi-file-detector' into 'master'

Fix OpenAPI file detector

See merge request gitlab-org/gitlab!27321
parents 7e3afaaa 7eba276a
---
title: Fix OpenAPI file detector
merge_request: 27321
author: Roger Meier
type: fixed
...@@ -40,7 +40,7 @@ module Gitlab ...@@ -40,7 +40,7 @@ module Gitlab
yarn_lock: 'yarn.lock', yarn_lock: 'yarn.lock',
# OpenAPI Specification files # OpenAPI Specification files
openapi: %r{.*(openapi|swagger).*\.(yaml|yml|json)\z}i openapi: %r{([^\/]+)*(openapi|swagger)([^\/]+)*\.(yaml|yml|json)\z}i
}.freeze }.freeze
# Returns an Array of file types based on the given paths. # Returns an Array of file types based on the given paths.
......
...@@ -96,14 +96,25 @@ describe Gitlab::FileDetector do ...@@ -96,14 +96,25 @@ describe Gitlab::FileDetector do
'swagger.yml', 'swagger.yaml', 'swagger.json', 'swagger.yml', 'swagger.yaml', 'swagger.json',
'gitlab_swagger.yml', 'openapi_gitlab.yml', 'gitlab_swagger.yml', 'openapi_gitlab.yml',
'OpenAPI.YML', 'openapi.Yaml', 'openapi.JSON', 'OpenAPI.YML', 'openapi.Yaml', 'openapi.JSON',
'openapi.gitlab.yml', 'gitlab.openapi.yml' 'openapi.gitlab.yml', 'gitlab.openapi.yml',
'attention/openapi.yml', 'attention/swagger.yml',
'attention/gitlab_swagger.yml', 'attention/openapi_gitlab.yml',
'openapi/openapi.yml', 'openapi/swagger.yml',
'openapi/my_openapi.yml', 'openapi/swagger_one.yml'
] ]
openapi_types.each do |type_name| openapi_types.each do |type_name|
expect(described_class.type_of(type_name)).to eq(:openapi) expect(described_class.type_of(type_name)).to eq(:openapi)
end end
expect(described_class.type_of('openapiyml')).to be_nil openapi_bad_types = [
'openapiyml',
'openapi/attention.yaml', 'swagger/attention.yaml'
]
openapi_bad_types.each do |type_name|
expect(described_class.type_of(type_name)).to be_nil
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment