OpenAPI Schema generation missing titlte

2017-08-28 Thread Dan Davis
Hi guys, 

I'm trying to understand what I would need to do to get the schema 
generation to include verbose_name from my model or a label from a 
serializer form.  I'm converting the schema all the way through to to try 
to drive a React schema-driven form using the javascript package 
reach-jsonschema-form, playground for which 
is https://mozilla-services.github.io/react-jsonschema-form/.

However, the OpenAPI schema generated does not include a label for a field, 
whether I specify it as the verbose_name on my model, or as the label on 
Serializer.   

I've tried to look at the CoreAPI intermediate form, for which I post the 
following:

Field(name='barcode', required=True, location='form', 
schema=, 
description=None, type=None, example=None)
Field(name='universal_sequence', required=True, location='form', 
schema=, 
description=None, type=None, example=None)
Field(name='index_sequence', required=True, location='form', 
schema=, 
description=None, type=None, example=None)
Field(name='full_sequence', required=True, location='form', 
schema=, 
description=None, type=None, example=None)
Field(name='index_type', required=True, location='form', 
schema=, 
description=None, type=None, example=None)


You can see some of the Python from which I produced this brief result in a 
Gist - https://gist.github.com/danizen/6f441f575d04258329d65ba25ec2ea74

If you need more, the whole code is in GitHub - 
https://github.com/NCBI-Hackathons/OnlineAdapterDatabase/tree/dan/tryreact


I'm posting here because I've eliminated django-rest-swagger from the tools 
- the API is using purely Django rest framework, with a custom renderer 
based on the openapi_codec package, as shown in the Django Rest Framework 
documentation.   I've come a long way in understanding how CoreAPI is an 
sometimes internal view, but a schema view can be made external.   I've 
made that an operation on a ViewSet so that it can be browsed through the 
API explorer itself.

The problem here is getting it to include the title for a form...

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I change error messages format in DRF?

2017-08-28 Thread Marlysson Silva
Catching the serializer.errors and format your own error container don't 
work?

Em sexta-feira, 25 de agosto de 2017 13:19:11 UTC-3, Serge Efremov escreveu:
>
> This is what I do. I have a Serializer-level validator that checks the 
> validity of a number of fields. If they a missing or incorrect I want to 
> display a specific error message. Which basically looks like this.
>
> {
> 'errors': {
> '__all__': ['missing_security_fields'],
> },
> 'errors:context': {
> '__all__': {
> 'missing_security_fields': ['pow_1', 'pow_2', 'ticket'],
> },
> },
> }
>
> This is how it looks in (simplified) code:
>
> class SecurityFieldsValidator(object):
> def __call__(self, value):
> missing_fields = self.get_missing_fields(value)
> if missing_fields:
> errors = {
> '__all__': ['missing_security_fields'],
> }
> context = {
> '__all__': {
> 'missing_security_fields': missing_fields,
> },
> }
> raise ValidationError({'errors': errors, 'errors:context': 
> context})
>
>
> But at some point in a call stack this structure stumbles upon 
> as_serializer_error() function (get_validation_error_detail() in older 
> versions) which wraps every item inside my dictionary in a list. What I 
> would like to do is to override this function so that it doesn't do it (at 
> least not for this specific format). But since it is not a method of 
> Serializer class (BTW why?) and there seems to be no setting that could 
> override this function, I don't see how I could change its behavior. One 
> workaround I see is when this function is done with its job, walk over my 
> dict and unwrap every item from its list, which looks like a complete waste 
> of CPU. Another option is to override run_validation() method of my 
> serializer which also doesn't seem nice because other than this problem, 
> I'm completely OK with how it works and I don't want to copy its code into 
> my project just to change a call of one function.
>
> Did anyone try to implement their own error format and how one could 
> circumvent this rather annoying and seemingly hardcoded behavior?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Regular serializer in browsable api

2017-08-28 Thread Marlysson Silva
Can you post your Serializer?

Em domingo, 27 de agosto de 2017 12:54:32 UTC-3, Ivlev Denis escreveu:
>
>
> Hi.
> I have ModelSerializer with field of regular Serializer, them not showed 
> in browsable api. What am I doing wrong?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Regular serializer in browsable api

2017-08-28 Thread Xavier Ordoquy
Hi,

The question is a bit too opened to be answered.
https://medium.com/django-rest-framework/django-rest-framework-viewset-when-you-don-t-have-a-model-335a0490ba6f
 

 may help you to get something working.

Regards,
Xavier Ordoquy,
Linovia.

> Le 27 août 2017 à 17:54, Ivlev Denis  a écrit :
> 
> 
> Hi.
> I have ModelSerializer with field of regular Serializer, them not showed in 
> browsable api. What am I doing wrong?
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-rest-framework+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.