Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Error in host #482

Closed
vtisnado opened this issue Jul 16, 2016 · 8 comments
Closed

Error in host #482

vtisnado opened this issue Jul 16, 2016 · 8 comments

Comments

@vtisnado
Copy link

vtisnado commented Jul 16, 2016

Hi,
I'm getting an error in the Swagger API page at the end of the page near [ BASE URL: ]. Checking in the online validator says that the host is empty.

There is any configuration I forgot in the settings.py? I'm sorry if this is not the place to put this question, but I can't find any related info in the documentation and examples. Thanks in advance.

{
   "schemaValidationMessages":[
      {
         "level":"error",
         "domain":"validation",
         "keyword":"pattern",
         "message":"ECMA 262 regex \"^[^{}/ :\\\\]+(?::\\d+)?$\" does not match input string \"\"",
         "schema":{
            "loadingURI":"#",
            "pointer":"/properties/host"
         },
         "instance":{
            "pointer":"/host"
         }
      }
   ]
}

You can check the error here: http://loyalty.copiaypega.net/doc/

@tomchristie
Copy link
Contributor

tomchristie commented Aug 11, 2016

Did you resolve this issue? (I see the link is now loading correctly)

@rloomans
Copy link

I'm still getting this issue at https://measuremate.herokuapp.com/docs/

@marcgibbons
Copy link
Owner

@tomchristie @rloomans I've fixed in a feature branch but haven't had the chance to push it up yet. It's a bit hacky; I'm setting the host by using the renderer_context's request.get_host inside the renderer. Hoping to have some time to push this week/weekend.

@tomchristie
Copy link
Contributor

It's a bit hacky; I'm setting the host by using the renderer_context's request.get_host inside the renderer.

Okey doke. That sounds like a reasonable enough approach, although let me know if you'd like a second set of eyes on it. Really we ought to make sure that you can get the host information from the Document url.

@marcgibbons
Copy link
Owner

@tomchristie Agreed. Ideally, the url would be set by the SchemaGenerator and do so dynamically based on the schema view's request. Since it's optional on the generator though, how do you think it could be accomplished?

@tomchristie
Copy link
Contributor

Perhaps this?...

  1. Attempt to get it from Document.url.
  2. Fallback to getting it from the request in the renderer context.

Also an option that we could make the request argument in get_schema be mandatory, and only ever generate schemas from with view code.

@marcgibbons
Copy link
Owner

@tomchristie 👍 for the fallback.

Making the request mandatory for the schema generation might be a good idea, not only for solving this particular problem, but also to support views which multiple serializer classes based on an evaluation of the request.user for example.

The downside is that users would have to be logged in to view the schema for endpoints which don't allow anonymous access. Perhaps this could be controlled with a boolean on the generator (i.e. filter_by_user) rather than explicitly including/excluding the request?

@tomchristie
Copy link
Contributor

tomchristie commented Aug 11, 2016

Ah yeah, I'd rather forgotten about the use case of "present all the information, even if the current user does not have permissions to all the endpoints". For now let's keep it optional. We may be able to finesse that in the future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants