Merge pull request #11777 from heww/fix-issue-11771

fix(swagger): enable security in swagger.yaml
This commit is contained in:
He Weiwei 2020-04-28 12:08:16 +08:00 committed by GitHub
commit 9cc7a5547a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -518,7 +518,6 @@ swagger_client:
mkdir -p harborclient/harbor_client
mkdir -p harborclient/harbor_swagger_client
mkdir -p harborclient/harbor_v2_swagger_client
sed -i "/type: basic/ a\\security:\n - basicAuth: []" api/v2.0/swagger.yaml
java -jar swagger-codegen-cli.jar generate -i api/swagger.yaml -l python -o harborclient/harbor_client -DpackageName=client
java -jar swagger-codegen-cli.jar generate -i api/v2.0/legacy_swagger.yaml -l python -o harborclient/harbor_swagger_client -DpackageName=swagger_client
java -jar swagger-codegen-cli.jar generate -i api/v2.0/swagger.yaml -l python -o harborclient/harbor_v2_swagger_client -DpackageName=v2_swagger_client

View File

@ -13,8 +13,11 @@ produces:
consumes:
- application/json
securityDefinitions:
basicAuth:
basic:
type: basic
security:
- basic: []
- {}
paths:
/projects/{project_name}/repositories:
get:

View File

@ -23,7 +23,12 @@ class Credential:
self.password = password
def _create_client(server, credential, debug, api_type="products"):
cfg = swagger_client.Configuration()
cfg = None
if api_type in ('projectv2', 'artifact', 'repository', 'scan'):
cfg = v2_swagger_client.Configuration()
else:
cfg = swagger_client.Configuration()
cfg.host = server.endpoint
cfg.verify_ssl = server.verify_ssl
# support basic auth only for now