format

How to specify alternative response formats with swagger/OpenAPI?

邮差的信 提交于 2019-12-22 04:49:38
问题 I have a swagger.yaml something like this: swagger: "2.0" paths: /something: get: parameters: - name: format in: query type: string pattern: '^(csv|json|xml)$' responses: 200: schema: type: ? And I want to return different formats (csv, json, xml) depending on the value of the format query parameter (eg. localhost/api/something?format=csv). How can I specify the different response formats in the spec? 回答1: I found a workaround, by providing different endpoints: swagger: "2.0" paths:

Format decimal as currency based on currency code

佐手、 提交于 2019-12-22 04:45:27
问题 I have a table of charges with the amount, and the currency code (USD, JPY, CAD, EUR etc.), and am looking for the easiest way to properly format the currency. Using my local culture code (USA) and taking my decimal.ToString("c") gets me $0.00 output, but I'd like the correct currency sign and number of decimals based on the code. Do any libraries exist for this? I can of course write up a switch statement and custom rules for each one, but thought this must have been done before. Update: I

In Delphi 7, how do I escape a percent sign (%) in the Format function?

自闭症网瘾萝莉.ら 提交于 2019-12-22 02:51:48
问题 I want to do something like this: SQL.Text := Format('select foo from bar where baz like ''%s%''',[SearchTerm]); But Format doesn't like that last '%', of course. So how can I escape it? \% ? %% ? Or do I have to do this: SQL.Text := Format('select foo from bar where baz like ''%s''',[SearchTerm+'%']); ? 回答1: Use another % in the format string: SQL.Text := Format('select foo from bar where baz like ''%s%%''',[SearchTerm]); 回答2: %% , IIRC. 回答3: Obligatory: http://xkcd.com/327/ :-) Depending on

SAS change date format

两盒软妹~` 提交于 2019-12-22 01:01:09
问题 I want to define a date format that takes the following format : 12JAN2010 I tried using this code : /* partie B question 2*/ data projet.Ophtalmo_new; set projet.Ophtalmo_new (RENAME=(date_diagnostic=date_dia)) (RENAME= (date_examen=date_exa)); date_diagnostic = input (date_dia, DDMMYY10.); date_examen = input (date_exa, DDMMYY10.); format date_diagnostic date_examen date9.; run; But it sends me the following syntax error : ERROR 22-322: Syntax error, expecting one of the following: un nom,

Python: Print to one line with time delay between prints

这一生的挚爱 提交于 2019-12-21 20:38:58
问题 I want to make (for fun) python print out 'LOADING...' to console. The twist is that I want to print it out letter by letter with sleep time between them of 0.1 seconds (ish). So far I did this: from time import sleep print('L') ; sleep(0.1) print('O') ; sleep(0.1) print('A') ; sleep(0.1) etc... However that prints it to separate lines each. Also I cant just type print('LOADING...') since it will print instantaneously, not letter by letter with sleep(0.1) in between. The example is trivial

php mysql storing line breaks in text area in database

笑着哭i 提交于 2019-12-21 20:24:43
问题 I have an input textarea and I would like to store the line breaks that a user makes in the text area in the database, so that it echoes the output text the same way as in the input text eg: Some text some text some text some text new line some text some text new line new line some text new line some text this is my current upload script: $sql = "insert into people (price, contact, category, username, fname, lname, expire, filename) values (:price, :contact, :category, :user_id, :fname,

JQgrid json date format

元气小坏坏 提交于 2019-12-21 16:19:50
问题 I have a date that is passed into my JQGrid via a Json string and it looks like "31/10/2011" I cannot work out the formatting via the JQGrid documentation. I just want it to appear and then be sortable in the grid. If I post without formatting, the date looks fine but is not recognised as a date, thus the sorting is all wrong. If I add the following date formatting to the column formatter: 'date', formatoptions: { newformat: 'd/m/Y'} I am getting a date back that looks like this 03/10/2031 I

jquery display formatted json

怎甘沉沦 提交于 2019-12-21 07:44:39
问题 Hi i have a problem becouse my json isn't display as formatted json. in my web page i have a <pre></pre> tag, it cointains json string: json example: {"status": "OK", "output": {"pools": [{"stats": {"bytes_used": 0, "objects": 0, "kb_used": 0}, "name": "data", "id": 0}, {"stats": {"bytes_used": 0, "objects": 0, "kb_used": 0}, "name": "metadata", "id": 1}, {"stats": {"bytes_used": 0, "objects": 0, "kb_used": 0}, "name": "rbd", "id": 2}], "stats": {"total_used": 63330648, "total_space":

Why is String's format(Object… args) defined as a static method?

断了今生、忘了曾经 提交于 2019-12-21 06:53:09
问题 I wonder why Java 5 and above provide a printf-style formatter using a static method in class String like this: public static String format(String format, Object... args) instead of public String format(Object... args) so that we can write "%02d".format(5) to get 05 instead of String.format("%02d", 5) . I imagined if I could modify the String class, I could add this: public String format(Object... args) { return format(this, args) } to get the same result. I found that in C#, a static method

Why is String's format(Object… args) defined as a static method?

亡梦爱人 提交于 2019-12-21 06:52:44
问题 I wonder why Java 5 and above provide a printf-style formatter using a static method in class String like this: public static String format(String format, Object... args) instead of public String format(Object... args) so that we can write "%02d".format(5) to get 05 instead of String.format("%02d", 5) . I imagined if I could modify the String class, I could add this: public String format(Object... args) { return format(this, args) } to get the same result. I found that in C#, a static method