Skip to content

Commit 10630a4

Browse files
committed
openapi
1 parent f4a7c7f commit 10630a4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

srv/codegen_apistuff.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,11 @@ func codegenOpenApi(apiRefl *apiReflect) (didFsWrites []string) {
214214
Info: yopenapi.Info{
215215
Title: Cfg.YO_APP_DOMAIN, Version: time.Now().Format("06.__2"),
216216
Descr: str.Repl(str.Replace(`
217-
**tl;dr:** mostly API calls will just-work as expected without knowing all the below notes (which elaborate mostly to-be-expected software-dev-commonplaces) — but in case of unexpected results or errors, they'll likely help.
218-
___
219-
This HTTP API has RPC rather than REST semantics. All operations are ´POST´, regardless of what CRUDs they might run (or not).
217+
This HTTP API has RPC rather than REST semantics: **all** operations are ´POST´, regardless of what CRUD writes or reads they might or might not effect.
220218
219+
**tl;dr:** mostly **API calls will just-work as expected _without_ knowing all those intro notes** immediately below (which elaborate mostly to-be-expected software-dev-commonplaces),
220+
- but in any cases of unexpected results or errors, they'll likely help complete the mental picture.
221+
___
221222
Our backend stack's convention-over-configuration designs yield a few request/response rules that remain **always in effect across all listed operations**:
222223
- Whereas request and response bodies are operation-specific, all operations share the exact-same set of request headers, URL query-string parameters and response headers (albeit being elaborated here identically and redundantly for each individual operation).
223224
- Request bodies **must never** be empty or the JSON ´null´: the empty request body is the JSON ´{}´.
@@ -229,13 +230,13 @@ Our backend stack's convention-over-configuration designs yield a few request/re
229230
- Caution for some client languages: this means ´null´ for many-if-not-most empty JSON arrays (although ´[]´ is principally always just-as-possible) and empty JSON dictionary/hash-map "object"s (with either ´null´ or ´{}´ principally equally possible).
230231
- All JSON object field names begin with an upper-case character,
231232
- any example to the contrary indicates a "free-style" JSON dictionary/hash-map "object".
232-
- The ´Content-Length´ request header is **required for all** operations.
233+
- The ´Content-Length´ request header is **required for all** operations (with a correct value).
233234
- The ´Content-Type´ request header is optional, but if present, must be correct with regards to both the operation's specification and the request body.
234235
- Any ´multipart/form-data´ operations:
235236
- **always require** the following two form-fields: ´files´ for any binary file uploads, and ´_´ for the actual JSON request payload;
236237
- only the latter is elaborated in this doc, and always in the exact same way as done for all the ´application/json´ operations, **without** specifically mentioning the ´_´ form-field containing the ´text/plain´ of the full ´application/json´ request payload actually being elaborated here.
237238
238-
How to read request/response example JSON values rendered in this doc:
239+
How to read request/response **example JSON values** rendered in this doc:
239240
- ´true´ indicates any ´boolean´ value, regardless of the actual real value in a call;
240241
- ´"someStr"´ indicates any ´string´ value;
241242
- signed-integer ´number´s are indicated by a negative-number example indicating the minimum (type-wise, not operation-specific) permissible value, with the maximum being the corresponding positive-number counterpart;
@@ -245,13 +246,17 @@ How to read request/response example JSON values rendered in this doc:
245246
- in responses, they're always UTC, whereas in requests, any timezone may be indicated;
246247
- in requests, they may always be ´null´ (excepting any operation-specific known-errors indicating otherwise) but must never be ´""´ or otherwise non-RFC3339/ISO8601-parseable.
247248
248-
More about error responses:
249+
About **error responses**:
249250
- All are ´text/plain´.
250251
- In addition to those listed in this doc (thrown by the service under the indicated conditions), other error responses are at all times entirely technically-possible and not exhaustively documentable (feasibly), such as eg. DB / file-system / network disruptions. Those caught by the service will be ´500´s, others (ie. from load-balancers / gateways / reverse-proxies etc. _in front of_ the service) might have _any_ HTTP status code whatsoever.
251252
- All the well-known (thrown rather than caught) errors listed here:
252253
- have their code-identifier-compatible (spaceless ASCII) enumerant-name as their entire text response, making all error responses inherently ´switch/case´able;
253254
- have been recursively determined by code-path walking. Among them are some that logically could not possibly ever occur for that operation, yet identifying those (to filter them out of the listing) is (so far) out of scope for our ´openapi.json´ generation.
254255
- Any non-known (caught rather than thrown) errors (not listed here) contain their original (usually human-language) error message fully, corresponding to the ´default´ in an error-handling ´switch/case´.
256+
- "Not Found" rules:
257+
- ´404´ **only** for HTTP requests of non-existing API operations or non-existing static-file assets,
258+
- ´400´ for operations where existence was definitely expected (such as some object's update identified by its ´Id´),
259+
- ´200´ with response-body of JSON ´null´ for requests of the "fetch single/first object found for some specified criteria" kind (where the definite-existence expectation does not necessarily hold).
255260
`, str.Dict{"´": "`"}), str.Dict{})},
256261
}
257262
openapi.Info.Contact.Name, openapi.Info.Contact.Url = "Permalink of "+filepath.Base(out_file_path), "https://"+Cfg.YO_APP_DOMAIN+"/"+StaticFilesDirName_App+"/"+filepath.Base(out_file_path)

0 commit comments

Comments
 (0)