Micronaut queryConfigEnabled - swagger-ui

I would like to activate the queryConfigEnabled swagger-ui property.
Is there a way to do that? Maybe in the openapi.properties or somewhere else?

If you are using gradle with java, you can try this one:
tasks.withType(JavaCompile) {
options.fork = true
options.forkOptions.jvmArgs << '-Dmicronaut.openapi.views.spec=rapidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop,swagger-ui.queryConfigEnabled=true'
...
}
So you can try to add swagger-ui.queryConfigEnabled=true to the end of jvmArgs

Related

How to pass params from Jenkins script to gradle

I got this code from my Jenkins groovy script:
./gradlew -PgroupParam='123' -PversionParam=${params.versionParam} clean build --info
I want to know how I we use these parameters (groupParam, versionParam) in my gradle.build file?
What is the best practice for it ?
In my gradle.build I tried to get them like this and it returned null:
def groupParam = System.getProperty("groupParam")
def versionParam = System.getProperty("versionParam")
And also this approach returned the same:
def groupParam = System.getenv("groupParam")
def versionParam = System.getenv("versionParam")
The parameters passed can be accessed using method project.getProperty(String). In your case you can use project.getProperty('groupParam') and project.getProperty('versionParam').
getProperty(String) will return MissingPropertyException incase the property does not exist so it is better to use menthod hasProperty(String) before you use getProperty().
if(project.hasProperty('groupParam')) {
// do this
}

grails cobertura findAllBy

I have grails 2.4.4 and Cobertura as covert test.
I have code like:
lstPerspectives = Perspectives.findAllByDbAndSysDelete(dbInstance, new Long(0))
But Cobertura don´t pass the test because don´t search in my DB, How can I pass this line?, How can overwrite this value? I send this lstPerspectives but it don´t take it.
Thanks
Thanks
Try something like the following:
import grails.test.mixin.Mock
import grails.test.mixin.TestFor
#TestFor(Perspectives)
#Mock([Perspectives])
class PerspectivesSpec
{
void "test Perspectives"(){
given:
def dbInstance = 'aDbInstance' // don't know what this is
def sysDelete = false // is this a boolean?
new Perspectives( dbInstance: dbInstance, sysDelete: sysDelete ).save( failOnError: true )
when:
// run you bit of code that executes the snippet in your question
then:
// check your desired outcome
}
}
I don't know if you are testing your Perspectives class directly here or something else, controller, service? so had to make a few assumptions.

How can I implement project based matrix security in jenkins using script?

I need to implement the project based security in jenkins using cli or dsl.
http://www.tothenew.com/blog/jenkins-implementing-project-based-matrix-authorization-strategy/
How can I do that?
I know this is old but just in case someone else runs across it...
For implementing it in a job DSL you can use this:
freeStyleJob('test_job_for_project_auth') {
authorization {
permission('hudson.model.Item.Discover', 'anonymous')
permissions('myUserOrGroup', [
'hudson.model.Item.Build',
'hudson.model.Item.Discover',
'hudson.model.Item.Cancel'
])
}
...
}
Here is the doc url:
https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.jobs.IvyJob.authorization

Groovy ConfigSlurper: how to modify a closure in a config?

I want to modify a grails BuildConfig.groovy:
grails.project.dependency.resolution = {
plugins {
build ":tomcat:7.0.50"
// plugins for the compile step
compile ":scaffolding:2.0.1"
compile ':cache:1.1.1'
// plugins needed at runtime but not for compilation
runtime ":hibernate:3.6.10.7" // or ":hibernate4:4.1.11.6"
runtime ":database-migration:1.3.8"
runtime ":jquery:1.10.2.2"
runtime ":resources:1.2.1"
}
}
Especially I want to add a plugin and modify another one.
I tried it with ConfigSlurper:
def conf = new ConfigSlurper().parse(new File(buildConfig).toURL())
def plugins = conf.grails.project.dependency.resolution
println "found plugins: $plugins"
plugins.each {
println it
}
The access to conf.grails.project.dependency works fine but conf.grails.project.dependency.resolution is a closure and I don't know how to access or even modify this section.
I don't know grails enough to make some opinionated guess, but it seems to me this config file doesn't conform to ConfigSlurper expected syntax. If what you want to parse isn't very long, you can try intercepting it yourself:
class PluginConfig {
def compileLibs = []
def runtimeLibs = []
def version
def build(version) { this.version = version }
def compile(lib) { compileLibs << lib }
def runtime(lib) { runtimeLibs << lib }
}
def conf = new ConfigSlurper().parse(new File("BuildConfig.groovy").toURL())
def plugins = conf.grails.project.dependency.resolution
def lib = new PluginConfig()
plugins.delegate = lib // magick!!
plugins()
assert lib.compileLibs == [":scaffolding:2.0.1", ':cache:1.1.1']
assert lib.runtimeLibs == [
":hibernate:3.6.10.7",
":database-migration:1.3.8",
":jquery:1.10.2.2",
":resources:1.2.1"
]
assert lib.version == ":tomcat:7.0.50"
No idea how to rewrite this to a file (easily) after the change, though. Maybe using Grails own config parser might be a better idea; it must have a representation of the config when it parses the file.
As far as I know there is no perfect way for doing this: all available parsers/slurpers drop the comments of your configuration. So even if you would modify the result from the config slurper and write it back, it wouldn't be what you are looking for.
You also have t consider that people might use variables for version numbers and other unexpected stuff.
So I guess the best way to modify the config is to use some regular expressions and hope that you users have a standard configuration...

putting the appname in a codenarc report title

just started with the codenarc plugin for grails - seems to be great!
But now I try to configure a dynamic report title like this:
"code quality report for ${appName}"
Unfortunately, it seems that the appName property is not available at the right time - I just get a null value.
Any ideas?
PS: using Grails 2.0.4 with ":codenarc:0.19"
appName is by default bound in BuildConfig.groovy but is not available to the configuration closure for codenarc. I am yet to become cognizant of an absolute reasoning behind that behavior, unless anyone here throws some light on it. But you can very well read application.properties directly to get the appName as below:
codenarc.reports = {
def props = new Properties()
new File("application.properties").withInputStream {props.load(it)}
MyHtmlReport('html') {
outputFile = "${props['app.name']} - CodeNarc-Report.html"
title = "${props['app.name']} - Sample Report"
}
}

Resources