Skip to content

Incorrect media-type for /search self link #216

@vincentsarago

Description

@vincentsarago

When creating the /search - GET|POST response we don't infer links, while we do it for `/items

item_collection = await self._search_base(search_request, request=request)
# If we have the `fields` extension enabled
# we need to avoid Pydantic validation because the
# Items might not be a valid STAC Item objects
if fields := getattr(search_request, "fields", None):
if fields.include or fields.exclude:
return JSONResponse(item_collection) # type: ignore
return ItemCollection(**item_collection)

links = await ItemCollectionLinks(
collection_id=collection_id, request=request
).get_links(extra_links=item_collection["links"])
item_collection["links"] = links

It will result in a self link with type="application/json", defined in

def link_self(self) -> Dict:
"""Return the self link."""
return {
"rel": Relations.self.value,
"type": MimeTypes.json.value,
"href": self.url,
}

curl http://127.0.0.1:8000/search | jq '.links[]'

...

{
  "rel": "self",
  "type": "application/json",
  "href": "http://127.0.0.1:8000/search"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions