Skip to content

Commit

Permalink
commit inicial
Browse files Browse the repository at this point in the history
  • Loading branch information
dunossauro committed Sep 25, 2019
1 parent 0eae95a commit 31418ba
Show file tree
Hide file tree
Showing 13 changed files with 923 additions and 0 deletions.
110 changes: 110 additions & 0 deletions .gitignore
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 added README.rst
Empty file.
5 changes: 5 additions & 0 deletions behave.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[behave]
lang = pt

[behave.userdata]
base_url = http://localhost:5000
18 changes: 18 additions & 0 deletions cvapi/__init__.py
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
37 changes: 37 additions & 0 deletions cvapi/schema.py
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)
Loading

0 comments on commit 31418ba

Please sign in to comment.