api-design

Why isn't viewWithTag and some other methods renamed in Swift 3?

雨燕双飞 提交于 2020-01-07 02:37:10
问题 In Swift 3, a lot of the methods got renamed. According to one of the sessions at WWDC, the prepositions in method names are moved to the parameter name: UIView.animateWithDuration(1) -> UIView.animate(withDuration: 1) UIStoryboard.instantiateViewControllerWithIdentifier("some stuff") -> UIStoryboard.instantiateViewController(withIdentifier: "some stuff") So I thought viewWithTag(1) will be renamed to view(withTag: 1) , but it isn't! There is even mentioned in the API guidelines: Especially

What's a RESTful way to query with filters?

痴心易碎 提交于 2020-01-04 06:13:18
问题 Say my application is managing objects called workload, with the following fields. I want to expose a REST interface for user to query workloads by labels. "Workload": {"id":"test1", "labels":["A", "B", "C"]} "Workload": {"id":"test2", "labels":["A", "C", "D"]} "Workload": {"id":"test3", "labels":["A", "B", "D"]} Question : How do I design the REST endpoint so that it would supports query workload by multiple labels as filter? Sample Query 1 : I want to GET all the workloads with both "A" and

flask_restplus' marshal_with returns response with null values

最后都变了- 提交于 2020-01-03 05:17:07
问题 I am using flask_restplus to create a documented API. The marshal decorator controls what data actually gets rendered in your response, but I am having trouble rendering the data. I have the following code: kpis_model = api.model('kpis', { 'cpl_actual': fields.Integer(description='costo por lead total del mes actual'), 'cpl_anterior': fields.Integer(description='costo por lead total del mes anterior'), 'cpl_diferencia': fields.Integer(description='diferencia de cpl_actual y cpl_anterior') })

How to manage relationship between 3 resources in REST API

故事扮演 提交于 2020-01-02 04:42:09
问题 I'm creating an API based on REST concept but I'm still a bit confused talking about relating resources. I've a website where people can signup in multiple groups and choose multiple roles. For example let's take people that signup in companies as scenario: Companies Facebook Google Apple Roles Marketing Sales Development Customer support So, when I want to create a user in a new company with certain roles, I would pass something like this into a POST request to /users endpoint { "username" :

Why there is no getFirst(iterable) method?

半腔热情 提交于 2019-12-30 05:32:08
问题 Iterables present two methods for getLast public static <T> T getLast(Iterable<T> iterable); public static <T> T getLast(Iterable<T> iterable, @Nullable T defaultValue); but only one for getFirst public static <T> T getFirst(Iterable<T> iterable, @Nullable T defaultValue); Is there are any design/implementation reason for breaking symmetry? 回答1: I think the point is that there is no reason for a getFirst(iterable) in that this could be done with iterable.iterator().next() . Guava makes an

Random high content download time in chrome?

限于喜欢 提交于 2019-12-29 05:57:31
问题 We have an API which randomly takes high content download time in chrome, It works fine always in firefox and takes an only few ms . The response size is 20kb uncompressed and 4kb compressed. The same request also works fine using curl. Things that we have tried: Disabling If-None-Match header to disable cache response from the browser. Trying various compressions (gzip, deflate, br). Disabling compression. Disabling all chrome extensions. The same request works fine sometimes on chrome but

Obtaining result from async API

为君一笑 提交于 2019-12-24 14:10:28
问题 I am building API for processing with Lumen, the processing job is taking around 1-3 seconds per request. So far i did it with job queue and beanstalkd and it is asynchronous, meaning i return job_id that i can check later for the result. I am also writing PHP client to utilize the API and for that i am wondering if i should include 'wait' parameter server side or client side? If wait is implemented serverside i will need to sleep and check the database for results once the job is dispatched

Open API inherited example data

馋奶兔 提交于 2019-12-24 11:37:50
问题 I'm using OpenAPI 3.0 to define an API for a service I am building. I'm running into an issue reusing schema components inside other components. For example, I have a Note object which contains a Profile object of the person who created the note. This works as expected by referencing the Profile object using the $ref keyword. The issue is when showing the example there isn't any data for the profile, and if I place the ref in the example like below it includes the actual OpenAPI block of

Creating user record / profile for first time sign in

倾然丶 夕夏残阳落幕 提交于 2019-12-24 11:28:38
问题 I use an authentication service Auth0 to allow users to log into my application. The application is a Q&A platform much like stackoverflow. I store a user profile on my server with information such as: 'about me', votes, preferences, etc. When new user signs in i need to do 1 of 2 things: For an existing user - retrieve the user profile from my api server For a new user - create a new profile on the database After the user signs in, Auth0(the authentication service) will send me some details

Wrapper's parseXXX() for signed binary misunderstanding

痴心易碎 提交于 2019-12-23 12:13:16
问题 Let's take Byte.parseByte() as an example as one of the wrappers' parseXXX() . From parseByte(String s, int radix)'s JavaDoc: Parses the string argument as a signed byte in the radix specified by the second argument. But that's not quite true if radix = 2 . In other words, the binary literal of -127 is 10000000 : byte b = (byte) 0b10000000; So the following should be true: byte b = Byte.parseByte("10000000", 2); but unfortunately, it throws NumberFormatException , and instead I have to do it