-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0eae95a
commit 31418ba
Showing
13 changed files
with
923 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
|
||
# Created by https://www.gitignore.io/api/python | ||
# Edit at https://www.gitignore.io/?templates=python | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# End of https://www.gitignore.io/api/python |
Empty file.
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,5 @@ | ||
[behave] | ||
lang = pt | ||
|
||
[behave.userdata] | ||
base_url = http://localhost:5000 |
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,18 @@ | ||
from flask import Flask, jsonify, request | ||
from .schema import ResumeSchema, configure_app | ||
from marshmallow.exceptions import ValidationError | ||
|
||
|
||
def create_app(): | ||
app = Flask(__name__) | ||
configure_app(app) | ||
|
||
@app.route('/validate-json', methods=['POST']) | ||
def validate_json(): | ||
try: | ||
ResumeSchema().load(request.json) | ||
return jsonify({'ok': 'Dados válidos'}), 201 | ||
except ValidationError as m_error: | ||
return jsonify(m_error.normalized_messages()), 400 | ||
|
||
return app |
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,37 @@ | ||
from typing import NoReturn | ||
from flask_marshmallow import Marshmallow, fields | ||
from flask_marshmallow.fields import fields | ||
|
||
ma = Marshmallow() | ||
|
||
|
||
class ResumeSchema(ma.Schema): | ||
name = fields.Str(required=True) | ||
profession = fields.Str(required=True) | ||
phone = fields.Str(required=True) | ||
email = fields.Str(required=True) | ||
address = fields.Str(required=True) | ||
portfolio = fields.Str(required=True) | ||
education = fields.List(fields.List(fields.Raw()), required=True) | ||
experience = fields.List(fields.List(fields.Raw()), required=True) | ||
skills = fields.List(fields.List(fields.Raw()), required=True) | ||
languages = fields.List(fields.List(fields.Raw()), required=True) | ||
|
||
class Meta: | ||
fields = ( | ||
'name', | ||
'profession', | ||
'phone', | ||
'email', | ||
'address', | ||
'portfolio', | ||
'education', | ||
'experience', | ||
'skills', | ||
'languages', | ||
) | ||
|
||
|
||
def configure_app(app) -> NoReturn: | ||
"""Configurar o app para ter o schema.""" | ||
ma.init_app(app) |
Oops, something went wrong.