from rest_framework.schemas import AutoSchema
import coreapi

class AuthSchema(AutoSchema):
    manual_fields = []

    def get_manual_fields(self, path, method):
        custom_fields = []
        if method.lower() == 'post':
            custom_fields = [
                coreapi.Field('username', required=True, location='form', description='Usuario'),
                coreapi.Field('password', required=True, location='form', description='Contraseña'),
            ]
        return self._manual_fields + custom_fields

class UsuarioSchema(AutoSchema):
    manual_fields = []

    def get_manual_fields(self, path, method):
        custom_fields = []
        if method.lower() == 'post':
            custom_fields = [
                coreapi.Field('rut', required=True, location='form', description='RUT'),
                coreapi.Field('nombres', required=True, location='form', description='Nombres'),
                coreapi.Field('apellido_a', required=True, location='form', description='Apellido A'),
                coreapi.Field('apellido_b', required=True, location='form', description='Apellido B'),
                coreapi.Field('email', required=True, location='form', description='Correo Electrónico'),
                coreapi.Field('login', required=True, location='form', description='Usuario'),
                coreapi.Field('clave', required=True, location='form', description='Contraseña'),
                coreapi.Field('vigente', location='form', description='Vigente'),
            ]
        return self._manual_fields + custom_fields

class ParaderoImageSchema(AutoSchema):
    manual_fields = []

    def get_manual_fields(self, path, method):
        custom_fields = []
        if method.lower() == 'post':
            custom_fields=[
                coreapi.Field('imagen', required=True, location='formData', type='file', description='Imagen a Subir')
            ]
        return self._manual_fields + custom_fields