open api 3 add multiple random examples for a single string item - openapi

I have a text.yaml - a single string item.
I want it to pass random string examples to my documentation to represent real life cases.
type: string
example:
- Example Text
- טקסט לדוגמא
- 123 text with numbers 456
description: localized text to show
tried with examples but it's not supported.
this doc - https://swagger.io/docs/specification/2-0/adding-examples/ does not list any valid parameters for this

Related

How to add multi-part Smart Health Cards to Apple Wallet and Health in Swift

I'm coding in Swift to add Smart Health Cards to Apple Wallet and Health using the guidelines here.
My code works fine with a single part JSON (i.e., shc:/5676290952432060346029243740... snipped for brevity). I am replacing the shc:/ prefix with https://redirect.health.apple.com/SMARTHealthCard/ to use with the Add to Apple Health and Wallet button as described in the link above.
The challenge is when the JSON is in multiple parts, i.e.,
shc:/1/3/567629095243206034602...
shc:/2/3/315057062436201156761...
shc:/3/3/634538347210283310097...
How can I assemble the QR code strings to add multiple vaccines to Apple Wallet and Health using the method described above using one Add to Apple Health and Wallet button? Things I've tried are using the shc:/ prefix on all QR codes in one long string, merging all JSON together and prefixing the entire string with https://redirect.health.apple.com/SMARTHealthCard/ and multiple variations of the above.
I found a solution and am posting here in case anyone else needs this information. What works for me is the following format:
https://redirect.health.apple.com/SMARTHealthCard/<QR string 1><QR string 2><QR string 3>
I removed all characters up to the trailing '/' in the QR codes. So all strings contain only numerics. I append all strings into 1 big string of numeric characters in the order of the ordinal number (i.e., 1/3, 2/3, 3/3). Then I pre-pend the redirect URL (https://redirect.health.apple.com/SMARTHealthCard/).

What function do I use in a Salesforce apex trigger to trim a text field?

I'm new to writing apex triggers. I've looked through a lot of the apex developer documentation, and I can't seem to find the combination of functions that I should use to automatically trim characters from a text field.
My org has two text fields on the Case object, which automatically store the email addresses that are included in an email-to-case. The text fields have a 255 character limit each. We are seeing errors pop up because the number of email addresses that these fields contain often exceeds 255 characters.
I need to write a trigger that can trim these text fields to the last ".com" before it hits the 255 character limit.
Perhaps I'm going about this all wrong. Any advice?
You can use replace() function in Apex.
String s1 = 'abcdbca';
String target = 'bc';
String replacement = 'xy';
String s2 = s1.replace(target, replacement);
If you need to use regular expression to find the pattern, then you can use replaceAll()
String s1 = 'a b c 5 xyz';
String regExp = '[a-zA-Z]';
String replacement = '1';
String s2 = s1.replaceAll(regExp, replacement);
For more information please refer Apex Reference Guide
The following code I think that covers what you are searching:
String initialUrl = 'https://stackoverflow.com/questions/69136581/what-function-do-i-use-in-a-salesforce-apex-trigger-to-trim-a-text-field';
Integer comPosition = initialUrl.indexOf('.com');
System.debug(initialUrl.left(comPosition + 4));
//https://stackoverflow.com
The main problems that I see are that other extensions are not covered (like ".net" urls) and that urls that have a ".com" appearing previous to the last one (something like "https://www.comunications.com"). But I think that this covers most of the use cases.
Why not increasing the length of that specific field? Trimming the text might cause data loss or unusable. Just go to object manager find that object and that specific field. Edit field and increase the length.

How to note a calculated default value in OAS3

I'm updating my API spec (OAS 3.0.0), and am having trouble understanding how to properly model a "complex" default value.
In general, default values for parameters are scalar values (i.e. the field offset has a default value of 0). But in the API I'm spec'ing, the default value is actually calculated based on other provided parameters.
For example, what if we take the Pet model from the example documentation, and decide that all animals need to be tagged. If the user of the API wants to supply a tag, great. If not, it will be equal to the name.
One possibility:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
default: '#/components/schemas/Pet/name'
This stores the path value as the default, but I'd like to have it explain that the default value will be calculated.
Bonus points if I can encode information from a parent schema.
Is the alternative to just describe the behavior in a description field?
OpenAPI Specification does not support dynamic/conditional defaults. You can only document the behavior verbally in the description.
That said, you can use specification extensions (x-...) to add custom information to your definitions, like so:
tag:
type: string
x-default: name
or
tag:
type: string
x-default:
propertyName: name
# or similar
and extend the tooling to support your custom extensions.

Substring and adding leading zeros to a string value

Hi all – I need some assistance with prefixing leading zeros into a string.
I have had a look around in the forum but did not quite find anything that suits my scenario.
The string in the column is in the following format: ‘INV-ACC-180 Some description etc’
The ‘INV-ACC-180’ bit is always the same format whilst the description can vary.
The challenge is the ‘180’. Its needs to be 4 leading zeros so it shows as 0180. i.e ‘INV-ACC-0180 Some description etc’
Some records may look like ‘INV-ACC-80 Some description etc’. And in this case the new correct format should be ‘INV-ACC-0080 Some description etc’
Many thanks in advance!
Is the 180 stored as a separate value ?
In that case you create 0180 using:
RIGHT('0000' + mynum, 4)
if the complete string is the input:
‘INV-ACC-' + RIGHT('0000'+substring(myinput,9,charindex(' ',myinput)-9),4) +substring(myinput,charindex(' '),1000)

MongoDB + Java + Search to fetch field or column names only after searching a string in a document using either full text or regular search

I am am in need of a solution quickly for the following:
Assuming that I have n numbere of documents in collection XYZ similar to below:
XYZ{
NAME: Test
AGE: 33
ADDRESS: ASDF
EDUCATION: BSC
}
If I want to search for a string say: "BSC"
I want the api to search for the string "BSC", and after successful search, it has to return me only the column name( or field name) of the document XYZ: "EDUCATION"
Any quick help for the solution of the above problem would be very helpful.
Thanks.
MongoDB does not allow you full text search, Sorry, I am not able to comment this one, Don't have appropriate points.