api-design

semantic versioning of API bundle

一曲冷凌霜 提交于 2019-12-06 07:44:53
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 the same time... 3.micro — A difference in the micro part does not signal any backward compatibility

How to handle sensitive properties in a RESTful API (such as passwords, credit cards, etc)

て烟熏妆下的殇ゞ 提交于 2019-12-06 07:36:24
问题 Working on a REST framework that will support multiple hypermedia types and authentication. One thing I'm not really sure how to handle are sensitive values in the resources. For instance, if I were to include user management in the API, I would need a way to expose to the client that there was a field for the password, but not show the actual password hash. Same thing with a credit card. If I don't, it would violate the hypermedia constraint as knowledge of the fields would become out of

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

流过昼夜 提交于 2019-12-06 07:28:35
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 "feeding" (e.g. functions such as tf.train.shuffle_batch , but even simple helpers like tf.one_hot ) apply

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

旧时模样 提交于 2019-12-06 07:15:42
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 this direct method safe for the specs? Swagger Inspector lets you make API calls and then create the

What http return code should be if no data available

倖福魔咒の 提交于 2019-12-06 02:01:33
问题 For example i have an api method /api/orders.getOrders which actually always exists. If this method returns no data in following format, should i send 404 or 200 http response code? { "orders":[] } 回答1: 200 is correct. From RFC 7231 The 4xx (Client Error) class of status code indicates that the client seems to have erred. The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource In your case, the client did not make a

RESTful API and bulk operations

半腔热情 提交于 2019-12-06 01:39:07
问题 I have a middle tier which performs CRUD operations on a shared database. When I converted the product to .NET Core I thought I'd also look at using REST for the API as CRUD is supposed to be what it does well. It seems like REST is a great solution for single record operations, but what happens when I want to delete, say, 1,000 records? Every professional multi-user application is going to have some concept of Optimistic Concurrency checking: you can't have one user wipe out the work of

Is it RESTful to create a foreign key record from another resources POST request?

匆匆过客 提交于 2019-12-05 22:47:52
So I have some resources in my API with foreign key relationships and these fk records (by design) cannot be created unless a POST is made to that specific resource first. I cannot create a Country by POSTing to Wine even though Country is a foreign key. the POST is going to /api/wine not /api/country In other words, if I send this payload to Wine resource: { id: 79, name: "Bordeaux", country: { id: 76, code: "FR", name: "France" }, year: "2005" } It will fail unless that country already exists. We cannot create the country from this POST because we are POSTing to the Wine resource and not

Best way to create REST API for long lasting tasks?

ぃ、小莉子 提交于 2019-12-05 17:44:06
问题 Suppose I have 2 servers. The first is a service that provides some computations, which can last long time (minutes to hours). The second server will use this service to have some data computed. I'm trying to design a REST API for the first server and so far so good. But I'd like to hear some opinion on how to model notifications when the long lasting task is finished. I considered 2 approaches so far: Polling - the second server will ask every now and then about the result. Callback - Second

What's a RESTful way to query with logic operation?

夙愿已清 提交于 2019-12-05 17:42:28
This is a spin-off question to query with filters 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 support query workload with basic logic operations? Sample Query 2 : I want to GET all the workloads with label "A" or "B" but no "C" No clue how to do this sort of rest api

Can I PUT without an ID?

旧巷老猫 提交于 2019-12-05 13:14:48
I'm designing an API Rest service that allows the user to upload a file to the server. I'm thinking this is a PUT request and it would go to server/resource/ID and have the file as base64 in the json request body. My question is regarding this ID. In my head, I'm passing the file to the server and the server should be in charge of storing that file and generating a unique ID to retrieve it later, and then return this ID to the client with an ok status. So I'm thinking about doing that, sending it to server/resource, without the ID, but is this ok or is it bad design? Tatsuyuki Ishi No. PUT