api-design

REST api design to retrieve summary information

亡梦爱人 提交于 2019-12-10 17:11:47
问题 I have a scenario in which I have REST API which manages a Resource which we will call Group. A Group is similar in concept to a discussion forum in Google Groups. Now I have two GET access method which I believe needs separate representations. The 1st GET access method retrieves the minimal amount of information about a Group. Given a group_id it should return a minimal amount of information like { group_id: "5t7yu8i9io0op", group_name: "Android Developers", is_moderated: true, number_of

REST API: Do I need to authenticate log out action?

送分小仙女□ 提交于 2019-12-10 15:27:43
问题 I'm writing a REST API server(using Rails), and here is a question about session management . I think for a REST API server, we don't need to save the log in state(or session ) for each user. So I just add an authentication token for each user. If they log in, this server will return this token to them, and if log out, destroy it. And I'm wondering if it's necessary to authenticate this token destroy action? There might be a malicious user who iterate all possible tokens( maybe! ) and wrap

How to merge/consolidate responses from multiple RESTful microservices?

帅比萌擦擦* 提交于 2019-12-10 14:27:14
问题 Let's say there are two (or more) RESTful microservices serving JSON. Service (A) stores user information (name, login, password, etc) and service (B) stores messages to/from that user (e.g. sender_id, subject, body, rcpt_ids). Service (A) on /profile/{user_id} may respond with: {id: 1, name:'Bob'} {id: 2, name:'Alice'} {id: 3, name:'Sue'} and so on Service (B) responding at /user/{user_id}/messages returns a list of messages destined for that {user_id} like so: {id: 1, subj:'Hey', body:

semantic versioning of API bundle

感情迁移 提交于 2019-12-10 10:53:01
问题 When starting with a package versioned at 1.0.0 in an API bundle, what should the new version be after adding a new interface to said package? The whitepaper makes this statement regarding compatibility: It should be obvious that binary compatibility plays an important role in backward compatibility. However, backward compatibility is also very dependent on the semantics. If the responsibility of an interface changes it could still be binary compatible but no longer be backward compatible. At

Link to another resource in a REST API: by its ID, or by its URL?

别等时光非礼了梦想. 提交于 2019-12-10 03:38:28
问题 I am creating some APIs using apiary, so the language used is JSON. Let's assume I need to represent this resource: { "id" : 9, "name" : "test", "customer_id" : 12, "user_id" : 1, "store_id" : 3, "notes" : "Lorem ipsum example long text" } Is it correct to refer to other resources by their IDs ( 12 , 1 , 3 ), or I should specify the URL of these resources (i.e. /customers/12 , /users/1 , /stores/3 )? I am not using HATEOAS and I am a bit confused. 回答1: DO include absolute entity URIs in your

Overriding ToString() for debugging and logs - should the string be localized?

ε祈祈猫儿з 提交于 2019-12-10 03:21:11
问题 I'm designing a .NET library that will be used by other developers making both web and desktop applications. I'm overriding ToString() in various classes to provide information for debugging purposes and for inclusion in application log files. Some of my classes contain numbers and dates. Consider an object that contains a DateTime called date and a double called value (and maybe other fields as well)... If I override that object's ToString() , I might want to do something like: public

Is it acceptable to return unmodifiableList or should I return array?

落花浮王杯 提交于 2019-12-08 14:38:11
问题 I have method List<Foo> getFoos () which gets the data from remote server and returns it. Of course, user shouldn't change number of items of the list because he'll get data not synchronized with data on the server (and if he want change number of items he has special methods like addFoo () ). First approach was to return array and change method's signature to Foo[] getFoos () . But it's more common in java and more convenient to user to operate with collections so I changed signature to List

Why doesn't FileExists support wildcards?

▼魔方 西西 提交于 2019-12-08 02:45:25
问题 Consider this example VBScript fragment: Dim fs Set fs = CreateObject("Scripting.FileSystemObject") If fs.FileExists("D:\Folder\File*.ext") Then ' Finds nothing! fs.CopyFile "D:\Folder\File*.ext", "D:\OtherFolder\" fs.Deletefile "D:\Folder\File*.ext" End If The FileExists method turns out not to support wildcards ( * and ? ). Not does FolderExists. I expected wildards to just work because they work fine for all similar methods in the FileSystemObject: CopyFile, CopyFolder, MoveFile,

What are the scenarios for which the various TensorFlow data loading idioms apply?

瘦欲@ 提交于 2019-12-08 02:15:42
问题 I have a TensorFlow deep learning workflow in which I have a fairly simple data reading and feeding pipeline built using regular NumPy; but I see that TensorFlow offers a large number of functions for loading data and building a data pipeline. I wonder though what scenarios these target. It seems there are two: learning that involves very large real world datasets, and networks built with the with the high-level TensorFlow API. It seems that the benefits of using "reading" as opposed to

Generate a Swagger file for certain endpoints from another Swagger or OpenAPI file

佐手、 提交于 2019-12-07 23:57:50
问题 Having one big Swagger/OpenAPI YAML specification, how can I safely extract certain API endpoints and generate a new .yaml for them exclusively? It's easy to identify API endpoints from a certain level (like defined with one indent or more): paths: /users: ... - $ref: '#/requests/getUser' /repos: ... requests: getUser: ... I'd just copy all sections, except paths , into a new specs file. And then I'd copy certain paths subsections like /users: based on indents. In Python, with a regex. But is