-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature bundled specs command (#116)
* use prance library to get bundled OAS Co-authored-by: Fernando Arruza <[email protected]>
- Loading branch information
Showing
7 changed files
with
124 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
version: "1.0.0" | ||
author: "API Team" | ||
email: "[email protected]" | ||
url: "http://swagger.io" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,17 @@ | |
swagger: "2.0" | ||
info: | ||
description: "This is a sample server Test server" | ||
version: "1.0.0" | ||
version: | ||
$ref: 'info.yaml#/version' | ||
title: "Swagger Test list" | ||
termsOfService: "http://swagger.io/terms/" | ||
contact: | ||
email: "[email protected]" | ||
name: | ||
$ref: 'info.yaml#/author' | ||
url: | ||
$ref: 'info.yaml#/url' | ||
email: | ||
$ref: 'info.yaml#/email' | ||
license: | ||
name: "Apache 2.0" | ||
url: "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
|
@@ -45,4 +51,5 @@ paths: | |
x-swagger-router-controller: "tests.test_flask" | ||
externalDocs: | ||
description: "Find out more about Swagger" | ||
url: "http://swagger.io" | ||
url: "http://swagger.io" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
"""Test common rest operations wrapper. | ||
""" | ||
import os | ||
from pathlib import Path | ||
import unittest | ||
from unittest.mock import patch | ||
|
||
|
@@ -9,6 +10,7 @@ | |
from pyms.cmd import Command | ||
from pyms.exceptions import FileDoesNotExistException, PackageNotExists | ||
from pyms.crypt.fernet import Crypt | ||
from pyms.flask.services.swagger import get_bundled_specs | ||
|
||
|
||
class TestCmd(unittest.TestCase): | ||
|
@@ -55,3 +57,20 @@ def test_startproject_error(self): | |
with pytest.raises(PackageNotExists) as excinfo: | ||
cmd.run() | ||
assert "cookiecutter is not installed. try with pip install -U cookiecutter" in str(excinfo.value) | ||
|
||
def test_get_bundled_specs(self): | ||
specs = get_bundled_specs(Path("tests/swagger_for_tests/swagger.yaml")) | ||
self.assertEqual(specs.get('swagger'), "2.0") | ||
self.assertEqual(specs.get('info').get('version'), "1.0.0") | ||
self.assertEqual(specs.get('info').get('contact').get('email'), "[email protected]") | ||
|
||
def test_merge_swagger_ok(self): | ||
arguments = ["merge-swagger", "--file", "tests/swagger_for_tests/swagger.yaml", ] | ||
cmd = Command(arguments=arguments, autorun=False) | ||
assert cmd.run() | ||
os.remove("tests/swagger_for_tests/swagger-complete.yaml") | ||
|
||
def test_merge_swagger_error(self): | ||
arguments = ["merge-swagger", ] | ||
cmd = Command(arguments=arguments, autorun=False) | ||
assert not cmd.run() |