RAML Merge descriptions - raml

Suppose we have a type Book declared as
type: object
properties:
bookId:
type: StringId
description: Book identifier
And a type StringId
type: string
description: UTF-8 string, max length 256 characters
Is there any way to merge descriptions from bookId in Book and StringId to get the final description of bookId rendered like this
Book identifier
UTF-8 string, max length 256 characters
I'm using raml2html tool for rendering
Thanks in advance!

Looks like it's not possible so far
Let's see if raml2html can be extended for that https://github.com/raml2html/raml2html/issues/425

Related

Unable to figure out what format is this

I'm querying a database and one of the fields contains a string in the following format:
ids {
Id: 12
Id: 12345
Id: 67891
}
Sorry if this is a stupid question, but this obviously isn't JSON since it doesn't have quotes, no commas to separate the values, and the keys are all the same.
Does anyone have any idea what the above format is called?
Thanks!

Open API Spec V2.0 - Default value of a field of type Enum

I have a request body for an API specification in Swagger V2.0, which looks like follows.
"/uri/path":
...
parameters:
- in: body
...
schema:
$ref: '#/definitions/StatusObject'
definitions:
StatusObject:
status:
$ref: '#/definitions/StatusEnum'
StatusEnum:
type: string
enum: ['ALPHA', 'BRAVO', 'UNKNOWN']
Now, I want StatusObject.status to have the value UNKNOWN by default, if it is not set from the client end. I tried to achieve this as follows, with no luck.
"/uri/path":
...
parameters:
- in: body
...
schema:
$ref: '#/definitions/StatusObject'
definitions:
StatusObject:
status:
$ref: '#/definitions/StatusEnum'
default: 'UNKNOWN'
StatusEnum:
type: string
enum: ['ALPHA', 'BRAVO', 'UNKNOWN']
I also have tried with '#/definitions/StatusEnum.UNKNOWN' which again didn't work. Combed through the documentation as well but couldn't find anything further. What am I missing?
Response to marked duplicate
What I am trying to achieve is to set a default value for this property status. This works when the enum is defined in line as follows.
"/uri/path":
...
parameters:
- in: body
...
schema:
$ref: '#/definitions/StatusObject'
definitions:
StatusObject:
status:
type: string
enum:
- 'ALPHA'
- 'BRAVO'
- 'UNKNOWN'
default: 'UNKNOWN'
But, this won't work for me, as I'd like to reuse the enum, which otherwise I'll have to repeat at multiple places.
Since this is just a workaround and I am not sure if I can confirm if this is an answer, I won't mark this as accepted answer. That way, I think it will be still open for someone who figured out the right way, or a better way to achieve the expectation.
Apparently, the problem is with $ref. It's already known that the siblings of $ref are ignored in OpenAPI V2.0. So, enforcing any further constraints once you use $ref won't be possible.
For my specific use case, since I want to reuse my enum definition, I used YAML Anchors as defined in V2.0 docs. Even though the enum definition is repeated in each POJO it's not that much of a headache to manage, at least for the time being. The implementation I came up is as follows.
"/uri/path":
...
parameters:
- in: body
...
schema:
$ref: '#/definitions/StatusObject'
definitions:
StatusObject:
status:
enum: *STATUS_ENUM # Referencing the anchor
default: 'UNKNOWN'
StatusEnum:
type: string
enum: &STATUS_ENUM # This is the anchor
- 'ALPHA'
- 'BRAVO'
- 'UNKNOWN'
It must also be noted that, the enum values in this case cannot be defined using array syntax (i.e. ['ALPHA', 'BRAVO', 'UNKNOWN']) as it'll break the YAML syntax rules when you try to use YAML anchors alongside that.

Getting the Short/Long Name of the Translate value

I have a Field naming SUBJECT with translate value:
Translate Value: Math
Long Name: Mathematics
Short Name: Mathematics
Now I have a Record naming PS_CLASS which has SUBJECT as field, now basically the values of SUBJECT in PS_CLASS would be 'Math'.
The problem is I want it to store the Long Name of that translate value, so instead of SUBJECT having 'Math' as value, it will have the value of 'Mathematics'.
Any idea how to do this?
Thanks!

raml2html not generating arrays declarations properly

I am using the raml2html tool to generate html documentation for my ReST apis.
I have defined all my types in a raml file memberTypes.raml that I include in the main service.raml.
Following is a sample from the service.raml file.
#%RAML 1.0
title: update member object
uses:
memberTypes: /memberTypes.raml
types:
Member:
properties:
termsAndConditions:
type: memberTypes.TermsAndConditions[]
description: The terms and conditions that the member has accepted.
required: false
person:
type: memberTypes.Person
description: The personal details of the member.
required: true
And following is a sample for the 2 properties above in memberTypes.raml
Person:
properties:
personName:
type: NameType
description: The name of the member.
required: true
dateOfBirth:
type: DateOfBirth
required: true
TermsAndConditions:
properties:
version:
type: string
description: The version of the terms and conditions.
acceptedDate:
type: date-only
description: The date on which the corresponding terms and conditions were accepted. Format is YYYY-MM-DD, ISO-8601 Calendar date format.
Now, below is the what I get in the html
The array is shown as array of memberTypes.TermsAndConditions. The questions is how do i get rid of the memberTypes? i simply want the type to be array of TermsAndConditions.
How do I achieve this? is there a command line option to raml2html tool that will do the trick?
I don't think there is command line option to do that, since the template / theme of raml2html defines how things are shown in HTML. You can edit the default theme. If I recall correctly that is defined in item.nunjucks file.
The usual use case for that is "array of objects" or "array of strings" but there is also definitions how to show non standard type types.

How to display rich text image (saved in Notes document) in XPages

Everyone keeps talking about opening the attachment. IT'S NOT AN ATTACHMENT! The image was pasted in a rich text field in Notes cocument. When I view the properties of one these Notes documents with the image, (unfortunately I'm not able to paste images to this), there are internal fields created for this rich text field namely MIME_Version, and the name of the rich text field listed four (4) times as shown below:
Field Name: myImage
Data Type: MIME Part
Data Length: 141 bytes
Seq Num: 3
Dup Item ID: 1
Field Flags: SIGN SEAL
"Content-Type: multipart/related; boundary="=_related 006391B688257C0D_="
This is a multipart message in MIME format.
"
___________________________________________________
Field Name: myImage
Data Type: MIME Part
Data Length: 150 bytes
Seq Num: 3
Dup Item ID: 2
Field Flags: SIGN SEAL
"--=_related 006391B688257C0D_=
Content-Type: text/html; charset="US-ASCII"
<img src=cid:_2_0BCE1D8C0BCE1ACC006391B688257C0D>
"
____________________________________________________
Field Name: myImage
Data Type: MIME Part
Data Length: 14064 bytes
Seq Num: 3
Dup Item ID: 3
Field Flags: SIGN SEAL
"--=_related 006391B688257C0D_=
Content-Type: image/jpeg
Content-ID: <_2_0BCE1D8C0BCE1ACC006391B688257C0D>
Content-Transfer-Encoding: base64
/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsK
CwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQU
FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCACtALUDASIA
AhEBAxEB/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W2UcChUXW4I1O3acCCbqKUaqZo6bSPkXww2zWrJiSFVweK/SafWrTV/2YdcMc4M0Oi3O
4OCNp8pvUV8DeB/hpd6qNMvItRtUWbDYYnK8nGQB7V96+Mb638Ffs26nol/fQHUbvQ544j03u0TA
AfXIFTKaM1Tkmfnt4G+IGveGdKgtNP1CS3gBV2REU4P4g19s/BPxfr/i7QhaXWsieAoGdJYwOPqF
r4w8A+Gx5tyJSB5iFFDdB/tfhX3h8BLC38IeHEWeePdMAkUBfLk+pFTGojRxZ8L69qN5ZfF3xMtt
eT2y/wBq3IPkyMmfnPoa6n9pLU5bz9muKKa5muGGq2pXzZC3c9M1VTwS/ir4sa5KNQtrGefWbkLD
O3JBkOD+Ndd+1t4OGjfs8aZGtzDeM2qwljbHdjrSvFu4JSPEfh3ezQarAI7qaFRgARyFR+hr1b49
X9wNM8GTx3U5mUODL5h3jjpnrXJ/CP4Zt4ivLdYdUgicIhcPG52Eg8Eqp9K9W+PngBjfeFfD41K2
aeOKT94iMQHUnIIxnPHpRzxW4+STPO ..."
_________________________________________________
Field Name: myImage
Data Type: MIME Part
Data Length: 54 bytes
Seq Num: 3
Dup Item ID: 4
Field Flags: SIGN SEAL
"--=_related 006391B688257C0D_=--
"
Can someone please let me know how to display this image saved in a Notes document, in Xpages. What type of XPages control should be used? Thanks in advance.
You can use simple data binding to bind to a Rich Text field in the current document.
In my case binding to document1 a field called OverviewPicsChildparts which contains a pasted image works fine.
However I am trying to display a pasted image into a repeat control whose source is a DocumentCollection of response documents to document1 which is not as straight forward it seems.
However I solved this by adding this code...
<xp:this.data>
<xp:dominoDocument var="doc"
action="openDocument"
documentId="#{javascript:AllResponseDocs.getNoteID()}" ignoreRequestParams="true">
</xp:dominoDocument>
</xp:this.data>
Into a panel inside the repeat control and then was able to use Simple Data Binding binding to doc the field I wanted like this...
<xp:inputRichText
id="inputRichText1"
value="#{doc.ProPicture}"
readonly="true"
style="width:198.0px;height:141.0px">
</xp:inputRichText>
it worked for me.
As Steve said, to display RichText data, you need the RichText control. Quite simple.
If the RichText data contains an image AND other data, like text or tables, things are different and much more complicated. In that case you need the NotesMIME classes to get the HTML representation of the RichText data, parse it, extract references to the image you want, then run through all MIME items to find the one holding the image data.
So in a nutshell: when the RichText contains the image alone, it's easy and Steve gave a good example. Otherwise it's complicated.

Resources