openapi-generator asciidoc limits parameter columns, omits type - openapi-generator

Is there a way to specify which columns appear in the Parameters section? For example I would like to use Schema/type instead of Pattern.
My configuration:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.3.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/target/openapi.json</inputSpec>
<generatorName>asciidoc</generatorName>
<configOptions>
<useIntroduction>true</useIntroduction>
</configOptions>
<skipValidateSpec>true</skipValidateSpec>
</configuration>
</execution>
</executions>
</plugin>
Here's the relevant source snippet:
/myapi/{resourceId}:
get:
tags:
- Api Operations
summary: Get a widget
description: Get a widget by its resource id
operationId: findOne
parameters:
- name: resourceId
in: path
required: true
schema:
type: string
- name: affiliateId
in: header
required: false
schema:
type: integer
format: int64
default: 256
And the relevant output snippet:
====== Header Parameters
[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Pattern
| affiliateId
|
| -
| 256
|
|===
Instead of the "Pattern" column I would like it show something like Schema along with the value of integer and/or int64.

I resolved the issue by editing the mustache templates:
After cloning the openapi-generator project, I found and copied the following two files from src/main/resources/asciidoc-documentation under modules (link): params.mustache and param.mustache, to my own project under /src/main/resources/openapi.
Then I opened params.mustache and did a find-and-replace from "Pattern" to "Data Type".
Similarly in param.mustache I replaced "{{{pattern}}}" with "{{dataType}}"
Then in the maven pom file plugin config for openapi-generator-maven-plugin I added the following element under the configuration element:
<templateDirectory>${project.basedir}/src/main/resources/openapi</templateDirectory>
Running mvn clean compile resulted in the desired output:
[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Data Type
| affiliateId
|
| -
| 256
| Long
Note: To arrive at the right model field name, I enabled debug under the configuration element: <verbose>true</verbose> then issued the command (something like): mvn org.openapitools:openapi-generator-maven-plugin:5.3.0:generate#my-execution-id -pl mysubmodule -X -l out.txt; open out.txt and search for "headerParams" or "affiliateId" and find the field name corresponding to data type, in my case there were "dataType" and "dataFormat" of which I chose the former.
Also note that I did not need to copy index.mustache or model.mustache etc. to my project, only the two template files mentioned above.

Related

Why can't I open a *.w file in the appBuilder?

I have a *.w file, referring to two include files ({incl\include_file.i}, {incl\do_something_file.i}). That first include-file contains the definition of a RECID variable "recordid":
DEF INPUT-OUTPUT PARAMETER recordid AS RECID.
I am capable to compile the *.w file, the listing file looks as follows: (just a fragment)
Prompt>findstr "recordid do_something" listing.txt
...
1 x DEF INPUT-OUTPUT PARAMETER recordid AS RECID.
...
1 x 1 {incl\do_something_file.i
2 x 1 INPUT-OUTPUT recordid
So, the compilation works. In top of that, I've checked the pairs of "&ANALYZE-SUSPEND" and "&ANALYZE-RESUME" clauses and everything is fine.
Nevertheless, I can't open the *.w file, as the mentioned RECID seems not to be known (errors 201 and 196).
Edit after first comments
This the exact error message I get while opening the *.w file, using the AppBuilder (I'm working with a Dutch version of the tool, hence the Dutch words in between):
---------------------------
Fout
---------------------------
This file cannot be analyzed by the AppBuilder.
Please check these problems in your file or environment:
** Onbekende veld- of variabelenaam - recordid. (201)
** .\incl\<do_something_file>.i Compilatiefout op regel 7. (196)
---------------------------
OK
---------------------------
Edit with more information on ANALYZE- clauses
I've launched following findstr command on my code with the following results:
Prompt>findstr /I "ANALYZE-RESUME ANALYZE-SUSPEND" <filename>.w
&ANALYZE-SUSPEND _VERSION-NUMBER ... GUI
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS ...
&ANALYZE-RESUME
...
I confirm that the number of &ANALYZE-SUSPEND clauses equals the number of &ANALYZE-RESUME clauses, they are in the right sequence (first a SUSPEND and then a RESUME) and none of them is commented out.
Does anybody have an idea what's going wrong?
The problem was caused by an include, being outside of an suspend resume clause, in order to solve such a situation the following command might be useful:
findstr /I "ANALYZE {incl" <source_file>.w
The result should look like the following:
...
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK C-Win
{incl\something.i}
{incl\something_else.i}
&ANALYZE-RESUME
...
You see following rules:
The number of suspends and resumes must be equal.
Every suspend is to be closed by a resume.
Not one of those can be commented out.
It is advised to have includes between the suspend and the resume.

How to remove duplicate lines in YAML format configuration files?

I have a bunch of manifest/yaml files that may or may not have these key value pair duplicates:
...
app: activity-worker
app: activity-worker
...
I need to search through each of those files and find those duplicates so that I can remove one of them.
Note: I know that to replace a certain string (say, switch service: to app:) in all files of a directory (say, dev) I can run grep -l 'service:' dev/* | xargs sed -i "" 's/\service:/app:/g'. I'm looking for a relation between lines.
What you call YAML, is not YAML. The YAML specification
very explicitly states that
keys in a mapping must be unique, and your keys are not:
The content of a mapping node is an unordered set of key: value node
pairs, with the restriction that each of the keys is unique. YAML
places no further restrictions on the nodes. In particular, keys may
be arbitrary nodes, the same node may be used as the value of
several key: value pairs, and a mapping could even contain itself as
a key or a value (directly or indirectly).
On the other hand some libraries have implemented this incorrectly, choosing to overwrite
any previous value associated with a key, with a later value. In your case, since
the values are the same, which value would be taken doesn't really matter.
Also your block style representation is not the only way to represent key-value pairs of a
mapping in "YAML", these duplicates could also be represented in a mapping, as
{...., app: activity-worker, app: activity-worker, .... }
With the two occurences not necessarily being next to each, nor on the same line. The
following is also semantically equivalent "YAML" to your input:
{...., app: activity-worker, app:
activity-worker, .... }
If you have such faulty "YAML" files, the best way to clean them up is
using the round-trip capabilities of
ruamel.yaml (disclaimer: I
am the author of that package), and its ability to switch except/warn
on faulty input containing duplicate keys. You can install it for your
Python (virtual environment) using:
pip install ruamel.yaml
Assuming your file is called input.yaml and it contains:
a: 1 # some duplicate keys follow
app: activity-worker
app: activity-worker
b: "abc"
You can run the following one-liner:
python -c "import sys; from ruamel.yaml import YAML; yaml = YAML(); yaml.preserve_quotes=yaml.allow_duplicate_keys=True; yaml.dump(yaml.load(open('input.yaml')), sys.stdout)"
to get:
a: 1 # some duplicate keys follow
app: activity-worker
b: "abc"
and if your input were like:
{a: 1, app: activity-worker, app:
activity-worker, b: "abc"}
the output would be:
{a: 1, app: activity-worker, b: "abc"}

lesscss-maven-plugin from biz.gabrys.maven.plugins : using <compilerOptions>

I succeed to compile less to css. But i cannot figure out how pass Compiler Options to the compiler in order to generate the mapping source file too.
From the doc, it should be a thing like :
<compilerOptions>
<compilerOption>dumpLineNumbers:all</compilerOption>
</compilerOptions>
But i get :
[INFO] Compiling 1 source to C:\workspaces\neon-dev\project\src\main\webapp\css
lesscss: couldn't open file dumpLineNumbers:all
Any hints ?
You have to pass options in command line style, e.g.:
<compilerOptions>
<compilerOption>--line-numbers=all</compilerOption>
</compilerOptions>
See all available options: http://lesscss.org/usage/index.html#command-line-usage-options.
Version 2.0 of the biz.gabrys.maven.plugins:lesscss-maven-plugin will have a simpler configuration e.g.:
<options>
<lineNumbers>all</lineNumbers>
</options>

Salt stack top.sls pillar order

I'm trying to understand how Salt order and prioritizes matched minions in a top.sls file for a Pillar.
I want Salt to prioritize my entries in the Pillar but I get seemingly random sorting orders (not first, not last, not alphabetical afaik). I have had a look at the order option but would prefer not to use it (if it is even available in Pillars?)
/srv/pillar/top.sls
base:
'*':
- users
'office-london-*':
- office.general.london
'office-ny-*':
- office.general.ny
'office-*-cust-*':
- office.cust
'office-*-cust-ntp*':
- office.cust-ntp
minions
office-london-cust -> office.general.london
office-london-cust-server1 -> office.cust
office-london-cust-ntp-server1 -> office.cust-ntp
office-ny-cust -> office.general.ny
office-ny-cust-server1 -> office.cust
office-ny-cust-ntp-server1 -> office.cust-ntp
Here are some links to Github issues I've had a look at without figuring this out:
https://github.com/saltstack/salt/pull/1287
https://github.com/saltstack/salt/issues/13657
https://github.com/saltstack/salt/issues/1432
https://github.com/saltstack/salt/issues/14723
The minion will look at each match line in order and add the corresponding sls file to its list of sls files to apply. The minion will then compile that list of sls files into a data structure in the same order they were defined in the top.sls.
Require statements and similar requisites can modify the order of execution

Use spaces into the tab titles with liferay tabs

I'm working with Spring MVC for portlets and liferay tabs. I'm having a problem to put spaces into the tab title. Let's say I want to define something like this inside a JSP:
<liferay-ui:tabs
names="Sample Tab 1, Sample Tab 2"
refresh="false"
value="${myControllerValue}"
>
<liferay-ui:section>
<jsp:include page='/jsp/myPage1.jsp' flush="true"/>
</liferay-ui:section>
<liferay-ui:section>
<jsp:include page='/jsp/myPage2.jsp' flush="true"/>
</liferay-ui:section>
</liferay-ui:tabs>
This is not working at all (Eventhough, it's exactly the example from the documentation) and the problem is just the spaces into the names (It works fine if I use names="tab1,tab2", but that's not what I want to show in the tab titles)
Besides, I need to control the tab I show from the controller. Something like this:
if(whatever){
renderrequest.setAttribute("myControllerValue", "Sample Tab 1");
}
And this causes another problem, because I need to show the tab names in several languages, so I'd need to pass the tab I want in the locale language to match the jsp id. The best thing to do would be to split the title from the tab id and use the tabValues param, but no idea how to do it...
I read something about redefine the Languages-ext.properties, but I just import the tab,
<%#taglib prefix="liferay-ui" uri="http://liferay.com/tld/ui" %>
So I don't have this properties file, and no clue how to solve it.
I'd really appreciate any kind of help with this issue.
Thanks in advance!
EDIT:
Trying to apply the answer posted below I'm having the next error:
07:26:12,297 ERROR [PortletLocalServiceImpl:542] com.liferay.portal.kernel.xml.DocumentException: Error on line 20 of document : cvc-complex-type.2.4.a: Invalid content was found starting with element 'resource-bundle'. One of '{"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":portlet-info, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":portlet-preferences, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":security-role-ref, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-processing-event, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-publishing-event, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-public-render-parameter, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":container-runtime-option}' is expected.
And this is my portlet.xml file:
<portlet-app
version="2.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<portlet-name>MyAPP</portlet-name>
<display-name>MyAPP</display-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<init-param>
<name>contextConfigLocation</name>
<value>/WEB-INF/portlet/MyAPP-portlet.xml</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<supported-locale>gl_ES</supported-locale>
<supported-locale>es_ES</supported-locale>
<resource-bundle>messages</resource-bundle>
<resource-bundle>content/Language</resource-bundle>
<portlet-info>
<title>MyAPP</title>
<short-title>MyAPP</short-title>
<keywords>MyAPP</keywords>
</portlet-info>
</portlet>
</portlet-app>
You can use Language.properties to have the exact title names you want in the tab.
In the <liferay-ui:tabs> you can have:
<liferay-ui:tabs
names="sample-tab-1, sample-tab-2"
refresh="false"
value="${myControllerValue}"
>
which are nothing but keys in the Language.properties files as:
sample-tab-1=Sample Tab 1
sample-tab-2=Sample Tab 2
You can define the Language.properties file in the portlet.xml as:
<portlet>
...
...
<resource-bundle>content/Language</resource-bundle>
...
</portlet>
And this file and other Language files would reside in the source package inside the content folder, something like this:
docroot
|
|--> src
|
|--> content
|--> Language.properties
|--> Language_en.properties
|--> Language_ja.properties
|--> Language_de.properties
...
So in your controller you would use:
if(whatever){
renderrequest.setAttribute("myControllerValue", "sample-tab-1");
}
More about Liferay Localization.

Resources