I'm running openapi-generator generate -i swagger.yml -g html2 -o swagger-out and in my swagger.yml file I have:
openapi: "3.0.0"
info:
title: "User Web-Service"
version: "0.1.0"
servers:
- url: api.myhost.com
description: "Server"
But I want pass the Server URL and Info Version as a parameter variable. Is it possible?
Thanks
It's not possible to use environment variables at the moment but you may consider using customized templates (with the -t option in the CLI) to achieve what you want.
Related
Hi I wanted to create swagger opn api client code after writing swagger yaml on swagger editor, When I am trying to write it is throwing several errors again and again.
openapi: 3.0.0
info:
description: |
Rest Server API .
version: 1.0.0-oas3
title: Implementation of GET API in Swagger
paths:
/details/:
get:
parameters:
- name: details
in: path
schema:
type: string
enum: ['all', 'message', 'successfulCalls','failedCalls']
default: all
required: true
definitions:
details:
type: object
properties:
details_name_test:
type: array
items:
$ref: '#/definitions/Call'
Call:
type: int
responses:
'200':
description: A list of calls (maybe filtered by details)
schema:
$ref: '#/definitions/details'
properties:
message:
type: string
'400':
description: 'Invalid request'
schema:
$ref: '#/definitions/details'
properties:
message:
type: string
Can someone please help me to fix it?
If you use openapi-generator, you can validate your openapi file before generating.
usage: openapi-generator-cli <command> [<args>]
The most commonly used openapi-generator-cli commands are:
author Utilities for authoring generators or customizing templates.
batch Generate code in batch via external configs.
config-help Config help for chosen lang
generate Generate code with the specified generator.
help Display help information about openapi-generator
list Lists the available generators
meta MetaGenerator. Generator for creating a new template set and configuration for Codegen. The output will be based on the language you specify, and includes default templates to include.
validate Validate specification
version Show version information used in tooling
See 'openapi-generator-cli help <command>' for more information on a specific command.
java -jar openapi-generator-cli-6.0.0.jar validate -i <your_openapi_file.yaml>
If your schema is valid, you can generate the code with jar file or docker.
Docker example:
docker run --rm \
-v ${PWD}:/local openapitools/openapi-generator-cli generate \
-i /local/<your_openapi_file.yaml> \
-g <choose_generator> \
-o /local/generated/
I had a pipeline with PowerShell task that run some python script. It worked without any problems.
After I convert my pipeline into YAML format to store it as code and got something like this (a part of whole yaml pipeline):
variables:
Build.SyncSources: false
REPO_PATH_DA: '/asdfg/qwerty'
REPO_PATH_DS: '/zxcvbn/tyuio'
PIP_REPO_HOST: 'bbbb.nnnn.yyyy.com'
PIP_REPO_URL: 'https://$(PIP_REPO_HOST)/api/pypi/pypi/simple'
PIP_VENV_NAME: 'my_test_venv'
SelectedBranch: ''
WorkingDirectory: $(System.DefaultWorkingDirectory)
…………………………………………….
- task: PowerShell#1
displayName: 'Install package'
inputs:
scriptType: inlineScript
inlineScript: |
.\$(PIP_VENV_NAME)\Scripts\activate
python.exe -m pip install --index-url=$(PIP_REPO_URL) --trusted-host=$(PIP_REPO_HOST) mypackage
python.exe -m pip install --index-url=$(PIP_REPO_URL) --trusted-host=$(PIP_REPO_HOST) $(WorkingDirectory)$(REPO_PATH_DA)\qwerty
And after I run this pipeline I get an error:
##[error]System.DefaultWorkingDirectory : The term 'System.DefaultWorkingDirectory' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I tried to change the name of variable in format: $(env:System_DefaultWorkingDirectory) , but no success. I suppose that predefined variables are not passed into yaml pipeline. Do you have any ideas how to resolve it?
Based on my test, the same script could work fine in my yaml pipeline. The $(WorkingDirectory) will be converted to paths xxx/xx/s.
To check if the predefined variable: $(System.DefaultWorkingDirectory) has been passed to Yaml Pipeline.
You could add a task to list all Environment variables:
steps:
- script: SET | more
In the task log, you could search the SYSTEM_DEFAULTWORKINGDIRECTORY and check if the variable exists.
For example:
If this environment variable exists, you could try to use the following format: $env:SYSTEM_DEFAULTWORKINGDIRECTORY
Here is the example:
variables:
Build.SyncSources: false
.....
WorkingDirectory: '$env:SYSTEM_DEFAULTWORKINGDIRECTORY'
If you couldn't find this variable, you can also check if there are equivalent variables.
For example:
BUILD_SOURCESDIRECTORY , BUILD_REPOSITORY_LOCALPATH
Is this a build or a release pipeline? If it's a release, you may need to use $(Pipeline.Workspace) instead of $(System.DefaultWorkingDirectory).
Also, have you tried using $(System.WorkingDirectory) directly in your Powershell task, instead of declaring a variable that references it?
According to the swagger documentation, I should be able to have common parameters that are shared by all operations. The problem is that when running codegen locally, the generated code does not have any of the common path parameters. The below yaml produces code for any language (I've tried two).
What is very confusing is that if I use this exact yaml in https://editor.swagger.io/, the generated code does have the path parameters. I ran this for two different languages, typescript:
And C#:
Left is the code generated in editor.swagger.io and right is my generated code by running codegen locally.
In both cases, the .swagger-codegen\VERSION the file is 3.0.20 which is the one I'm using but the code generated by https://editor.swagger.io/ does have the parameter paths.
This simple yaml file reproduces the issue:
openapi: 3.0.2
info:
title: title
version: 1.0.0
paths:
'/instances/{id}':
summary: Manipulate a particular instance
get:
responses:
'200':
description: Ok
content:
text/plain:
schema:
type: string
example: pong
summary: Fetches an instance
parameters:
- in: path
name: id
schema:
type: integer
required: true
components:
securitySchemes:
bearerAuth:
scheme: bearer
bearerFormat: JWT
type: http
The command line used for generation:
java ^
-classpath bin/swagger-codegen-cli.jar ^
-DdebugOperations ^
io.swagger.codegen.v3.Codegen ^
generate ^
-i enterpos-api.yaml ^
-l typescript-angular ^
-o generated-code/typescript-angular-builtin
And that generated this output: https://gist.github.com/alanboy/45ce792255e079dd0de4f70449ebf455. I feel like this might be wrong usage or something wrong with my yaml but I can't figure out what.
The problem is the Main class. I noticed that using the io.swagger.codegen.v3.Codegen class produces incorrect results :
java -classpath bin/swagger-codegen-cli.jar io.swagger.codegen.v3.Codegen <more>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
But this works:
java -jar bin/swagger-codegen-cli.jar <more>
Which led me to open MANIFEST.MF in the jar and notice the main class is actually this:
Main-Class: io.swagger.codegen.v3.cli.SwaggerCodegen
I then ran the command like this and everything worked as expected.
java -classpath bin/swagger-codegen-cli.jar io.swagger.codegen.v3.cli.SwaggerCodegen <more>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Official site of elasticsearch says the default config file exists in /home/username/.curator/curator.yml
https://www.elastic.co/guide/en/elasticsearch/client/curator/current/command-line.html
But there is no such folder.
Also, I tried creating curator.yml and give path using --config option. But, it throws me error
curator --config ./curator.yml
Error: no such option: --config
Installation was done using apt
sudo apt-get update && sudo apt-get install elasticsearch-curator
Help me create a config file as I want to delete my log-indexes
Please note that the documentation does not say it that file exists after creation, it says:
If --config and CONFIG.YML are not provided, Curator will look in ~/.curator/curator.yml for the configuration file.
The file must be created by the end user.
Also, if you installed via:
sudo apt-get update && sudo apt-get install elasticsearch-curator
but did not add the official Elastic repository for Curator, then you installed an older version. Please check which version you are running with:
$ curator --version
curator, version 5.4.1
If you do not see the current version (5.4.1 at the time this answer was added), then you do not have the appropriate repository installed.
The official documentation provides an example client configuration file here.
There are also many examples of action files in the examples
Yes, one needs to create both the curator.yml as well as action.yml files.
Since I am on centos 7, I happened to install curator from RPM, and in its default /opt/elastic-curator' I could follow up this good blog (but badly formatted!) : https://anchormen.nl/blog/big-data-services/monitoring-aws-redshift-with-elasticsearch/ to ge the files as follows(you may modify according to your needs) :
curator.yml
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
client:
hosts:
- <host1>
- <host2, likewise upto hostN >
port: 9200
url_prefix:
use_ssl: False
certificate:
client_cert:
client_key:
ssl_no_validate: False
http_auth:
timeout: 30
master_only: False
logging:
loglevel: INFO
logfile: /var/log/curator.log
logformat: default
blacklist: []
and an action.yml as follows :
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: rollover
description: Rollover the index associated with index 'name', which should be in the form of prefix-000001 (or similar),or prefix-YYYY.MM.DD-1.
options:
disable_action: False
name: redshift_metrics_daily
conditions:
max_age: 1d
extra_settings:
index.number_of_shards: 2
index.number_of_replicas: 1
2:
action: rollover
description: Rollover the index associated with index 'name' , which should be in the form of prefix-000001 (or similar), or prefix-YYYY.MM.DD-1.
options:
disable_action: False
name: redshift_query_metadata_daily
conditions:
max_age: 1d
extra_settings:
index.number_of_shards: 2
index.number_of_replicas: 1
I get this respond from CMD after checking the jmxeval plugin during setting up,
Command: check_jmxeval.bat
CMD output:
C:\Nagwin_x64\plugins>check_jmxeval.bat
org.kohsuke.args4j.CmdLineException: Argument "<filename>" is required
at org.kohsuke.args4j.CmdLineParser.parseArgument(CmdLineParser.java:448)
at com.adahas.tools.jmxeval.App.execute(App.java:43)
at com.adahas.tools.jmxeval.App.main(App.java:110)
Argument "<filename>" is required
java -jar jmxeval.jar <filename> [--schema <version>] [--set (--define) <name=value>] [--validate <boolean>]
--schema <version> : set schema version
--set (--define) <name=value> : set variable name to value
--validate <boolean> : set validation true|false, default is false
I am following the steps in google code project: https://code.google.com/archive/p/jmxeval/wikis/GettingStarted.wiki
Argument "<filename>" is required
You need to pass as argument to the script the path to the xml file containing the instructions on what to check