I have looked all over the net, trolled through spring-data-rest source code and tried to decipher how the JS for the hal-browser is trying to retrieve 'title' and 'doc' details for a resource. I have also discovered that there are
#RepositoryRestResource(
collectionResourceRel = "roles",
path = "roles",
itemResourceDescription = #Description("This is a test description")
)
Annotations I can put in the #Repostitory, but it doesn't seem to do anything.
Specifically, if you look at this example, how do I get "title|doc" to fill in"
I filed a ticket with spring and haven't heard back.
From what I can see the HAL Browser expects the link to contain the title property. In the example you linked:
{
"motd": "Welcome to the OSDI Example Action Platform OSDI API endpoint!!",
"_links": {
"osdi:people": {
"href": "http://api.opensupporter.org/api/v1/people",
"title": "The collection of people in the system"
}
...
}
The org.springframework.hateoas.Link class does not support that property as of version 0.19.0.RELEASE. No idea about the docs though...
Related
Could someone show me an example code of how I can use datatables/editor with Django rest framework?
My concern is the editor provided some data like this:
{"data": [
{
/*Actual data*/
}],
"action": "create"
}
But Django expects only this, with different Methods (DefaultRouter)
{
/*Actual data*/
}
My first idea was to manipulate by "to_internal_value", but I am not sure it is the best way.
Could someone please help me?
In the FHIR REST API, there are some standard parameters for all resources that can be used in the 'search' endpoints.
I need to use the '_profile' parameter on a search operation: https://www.hl7.org/fhir/search.html#profile
The HAPI FHIR documentation on implementing search operations (https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations_search.html) has a lot of examples, none mention the parameters that apply to all the resources, like '_profile'.
I also checked their test server online (http://hapi.fhir.org/resource?serverId=home_r4&pretty=true&resource=Observation) and I can't find a way to specify the '_profile' there, to see how it works.
At the code level, what I'm trying to do is this:
#Search
public List<Observation> getObservationsByProfile(??? profile)
{
...
if (profile == '...')
{
...
}
else
{
...
}
...
}
I don't know how to specify the annotations and type of the parameter so it binds to the value provided in the '_profile' param un the requested URL.
Is there any sample code or documentation I can refere to? Thanks.
The way to make the search work with the "_profile" parameters is this:
#Search
public List<Observation> getObservationsByProfile(#OptionalParam(name="_profile) UriParam profile)
{
...
if (profile == '...')
{
...
}
else
{
...
}
...
}
Even though the _xxx parameters apply to all the FHIR resources, the HAPI FHIR documentation doesn't include an example on how to use those in the search. Hope this helps as reference for others.
I used Springboot + Springfox + Spring Data Rest to generate my APIs and documentation.
It works great, except in SDR you can programmatically remove a REST method say "PUT" for a specific Entity.
ExposureConfiguration config = restConfig.getExposureConfiguration();
config.forDomainType(User.class).disablePutForCreation();
config.withItemExposure((metadata, httpMethods) -> httpMethods.disable(HttpMethod.PUT));
But Springfox/Swagger won't pick this up and still shows the method as available in the documentation.
Is there a way to tell Springfox/Swagger that it's now removed?
I hide method programmatically by spring-fox annotation:
#ApiOperation(value = "Description here.", httpMethod = "PUT", hidden = true)
I am building an API and I have few models which have a relationship with each other:
Asset
Location
User
I am able to get objects via api by accessing /asset/5 or /location/15
This is all fine and good, now I have started to include some relations with it.. so if asset 5 is related to location 15.. the return from /asset/5 now includes (using WITH) the location info with it.
example:
/asset/5
{
"id": 5,
--> "uri": http: //localhost/api/asset/5, <-- how do i generate/append this
"name": null,
"location": {
"id": 15,
"name": "jimUser",
--> "uri": "http://localhost/api/location/5" <-- how do i generate/append this
}
}
(the URI is not part of my schema.. I want to have it added to the response.)
all of the location info is now returned with the asset. exactly what am looking for..
What I am trying to do is find a way to populate those URI fields with a link that is direct to that entity. so on the /asset/ return that contains the related location info I want to be able to provide a link that goes directly to that location.
I am unable to find a way to generate the URI for either the main response (in this case it is asset) or for a relation (in this case it is location)
I am new to Laravel and am trying to basically mirror an application that has this same type of reponse.
Any help is appreciated.
Thanks
I tried working with $request, $router and many others.
Create an accessor for your uri attribute and set it to be appended automatically to the JSON response:
// Location.php
class Location
{
protected $appends = ['uri'];
...
public function getUriAttribute()
{
return '/api/locations/' . $this->id;
}
}
I work with "Search Console API v3" now.
When I use "webmasters.sites.list" method, I get site URLs and propery sets. Propery set for expample - "sc-set:B9KPftMA4RltK1LS61GR2g".
But I can't find any way to get REAL NAME for property set using API.
I can't show this id "sc-set:B9KPftMA4RltK1LS61GR2g" to client instead normal name.
Example of response:
"siteEntry": [ { "siteUrl": "example.com", "permissionLevel": "siteRestrictedUser" },
{ "siteUrl": "sc-set:2d0rU0BQiIHsmCH-HGZ1KA", "permissionLevel": "siteRestrictedUser" }
]
when you call sites.list it returns a list of site resources which contain
{
"siteUrl": "http://www.daimto.com/",
"permissionLevel": "siteOwner"
},
There is no way to get any additional information about the site than that. What i am not able to understand is why you appear to be getting back some kind of id.