Getting "structural error" while converting a Swagger 2.0 file to OpenAPI 3.0 - openapi

Snippet of my code:
insuranceCompanyNbr:
type: integer
totalDigits: 6
invoiceTypeInfo:
$ref: '#/definitions/invoiceTypeInfo'
submitterTypeId:
type: string
I get this error:
Error: Structural error at definitions.InvoiceType.properties.insuranceCompanyNbr.
should NOT have additional properties.
additionalProperty: totalDigits
How can I resolve this error?
I tried adding schema at the beginning of the code, it didn't work.

There's no totalDigits keyword in OpenAPI - neither in v. 2.0, nor in 3.x. You need to either remove this keyword, or prefix it with x- to make it an extension (that is, arbitrary metadata).

Related

How to replace deprecated SOBE Code in TYPO3 10.4

I inherited an old TYPO3 Extension using SOBE. As far as I unterstand it's deprecated, but it seems there is no documentation on how to replace it.
The Extension is using Backend Forms and the following line is throwing an error:
if (is_array($GLOBALS['SOBE']->editconf['tt_content']) && reset($GLOBALS['SOBE']->editconf['tt_content']) === 'new') {
The error is:
Cannot access protected property TYPO3\CMS\Backend\Controller\EditDocumentController::$editconf
The Var $GLOBALS['SOBE'] is still there, and there is also editconf, but it's not working.
How can I replace this code or rewrite it?
The SOBE object is part by part removed since years. As there are multiple ways for using it - see https://docs.typo3.org/c/typo3/cms-core/main/en-us/search.html?q=sobe&check_keywords=yes&area=default - you may need to take a closer look what is the exact part of replacing this code.
I would guess you can see more at https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.2/Deprecation-84195-ProtectedMethodsAndPropertiesInEditDocumentController.html?highlight=editconf.

Deserialize only few properties

When using Kotlin with Moshi to parse an api response, I receive quite a large JSON object back.
However, all of the examples I see, they create an object to pass to the adapter() that includes all of the properties. However, I only need 4-5 of them.
How can I accomplish this? Currently this doesn't work:
val moshi = Moshi.Builder().build()
val jsonAdapter = moshi.adapter(OnLoadUser::class.java)
val onLoadUser = jsonAdapter.nullSafe().lenient().fromJson(data)
It gives this error:
E/EventThread: Task threw exception
java.lang.IllegalArgumentException: Cannot serialize Kotlin type com.biz.app.models.OnLoadUser. Reflective serialization of Kotlin classes without using kotlin-reflect has undefined and unexpected behavior. Please use KotlinJsonAdapterFactory from the moshi-kotlin artifact or use code gen from the moshi-kotlin-codegen artifact.
at com.squareup.moshi.ClassJsonAdapter$1.create(ClassJsonAdapter.java:97)
at com.squareup.moshi.Moshi.adapter(Moshi.java:145)
at com.squareup.moshi.Moshi.adapter(Moshi.java:105)
It's really a large JSON object, and I only need 4 properties:
{
name: 'John Doe',
email: 'john.doe#gmail.com',
token: 'QWERTY',
guid: '1234-5678-ASDF-9012'
...
}
Annotate properties that you want to skip with #Transient, they will be omitted by moshi.
The issue was that I wasn't using the KotlinJsonAdapterFactory(). I had to add it:
val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
And also in the gradle.build, so that it was available as an import:
implementation("com.squareup.moshi:moshi-kotlin:1.12.0")
After doing this, it could properly parse the JSON data with a partial Kotlin object.

Use forward slash before template variable

For quite some time I am now trying to get the following template to work with twirl:
#for(service <- services) {
location /grpc/#service {
grpc_pass #service:8088;
}
}
services is a List[String]. While the template is properly converted into a scala template, that scala template does not compile:
nginx.template.scala:40: type mismatch;
found : play.twirl.api.TxtFormat.Appendable
(which expands to) play.twirl.api.Txt
required: Int
With line 40 being:
"""),format.raw/*18.9*/("""location /grpc/"""),_display_(/*18.25*/service/*18.32*/ {_display_(Seq[Any](format.raw/*18.34*/("""
Checking that file out in IntelliJ does not show any error on that line. Changing it to location #service works as expected.
Do I need to escape the forward slash somehow?
The following seems to fix the issue:
location /grpc/#{service}

Scala Dropwizard with Freemarker Views

Running latest Dropwizard (1.0.0) + the Scala (2.10.6) plugin.
Currently stumbling over properly rendering a Freemarker view.
My View:
case class SimpleStringView(str:String) extends View("/templates/simpleString.ftl")
Template:
<p>param 'str' has value ${str}</p>
Resource:
#GET
#Path("/echo/{echo}")
def echo(#PathParam("echo") echo:String) : SimpleStringView = new SimpleStringView(echo)
produces the following error:
" freemarker.core.NonStringException: For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), but this has evaluated to a method+sequence (wrapper: f.e.b.SimpleMethodModel):"
Changing "String" to "java.lang.String' in case class does not change the error message.
This does not look like a new problem and is most likely not Dropwizard but Freemarker + Scala related. Question however is: Has someone found a proper way around it ?
Thanks for your help

How can I get babel to support both arrow functions and flow syntax?

I have this code:
var loadTempImpersonationToken = (username: string): Promise => client({
uri: `endpoint`,
cache: false
})
As you can see, this includes both an arrow function, and flow type annotations. Babel supports arrow functions (in the es2015 & stage-0 presets) as well as stripping type annotations, in the react preset.
Simply combining the presets fails:
{"presets": [
"stage-0",
"react"
]}
Produces
Error: Parse Error: Line 1: Unexpected token : while parsing file: /Users/tmcw/src/example.js
How does one support these features in the same code?
Turns out I had misconfigured babel - it was reading a different .babelrc file than the one I had set up. Sorry for the noise!