How to access value of switchable fieldType dialog in magnolia 6.2 using .ftl languange - dialog

FYI I'm new in magnolia,
I'm trying to use switchable type field in dialog, here is my YAML look like :
form:
label: Confirmation Pop Up
tabs:
- name: Menu
label: Menu
fields:
- name: linkUrl
fieldType: switchable
label: Link Button Reject
class: info.magnolia.ui.field.ConfiguredSwitchableFieldDefinition
transformerClass: info.magnolia.ui.form.field.transformer.composite.SwitchableTransformer
options:
- name: intLink
label: Internal URL
selected: true
value: intLink
- name: extLink
label: External URL
value: extLink
fields:
- name: intLink
class: info.magnolia.ui.form.field.definition.LinkFieldDefinition
targetWorkspace: website
fieldType: link
appName: pages
label: Link Internal
description: Choose a page to link .
identifierToPathConverter:
class: info.magnolia.dam.app.ui.field.definition.DamUploadFieldDefinition
- name: extLink
label: Link External
class: info.magnolia.ui.form.field.definition.TextFieldDefinition
actions:
commit:
class: info.magnolia.ui.admincentral.dialog.action.SaveDialogActionDefinition
cancel:
class: info.magnolia.ui.admincentral.dialog.action.CancelDialogActionDefinition
I can get this value
options:
- name: intLink
label: Internal URL
selected: true
value: intLink
- name: extLink
label: External URL
value: extLink
by calling ${content.linkUrl} which will show "intLink" or "extLink",
so, how do I get value of this :
fields:
- name: intLink
class: info.magnolia.ui.form.field.definition.LinkFieldDefinition
targetWorkspace: website
fieldType: link
appName: pages
label: Link Internal
description: Choose a page to link .
identifierToPathConverter:
class: info.magnolia.dam.app.ui.field.definition.DamUploadFieldDefinition
- name: extLink
label: Link External
class: info.magnolia.ui.form.field.definition.TextFieldDefinition
Could anyone help me on this please?

If you look in the JCR for that node you'll probably see an item called linkUrlintLink and linkUrlextLink This is because the values aren't getting transformed and by default, the switchable field will concatenate the names. You should be able to access them through ${content.linkUrlintLink and ${content.linkUrlextLink. You also can use the DelegatingCompositeFieldTransformer class to strip the prepended name of the field names.

Related

Publishing react app to gitlab using template in backstage

I want to use templates in my local backstage and have been trying to publish a create-react-app to my gitlab instance, but keep getting the following
22022-10-21T22:36:25.000Z HTTPError: Response code 400 (Bad Request)
I have added the integration within my app-config yaml file. There is some connection happening, but seams that I have missed a required attribute for this request. For example, the title for a merge request was not given. A missed a required attribute for this request. For example, the title for a merge request was not given. Wondering whats another required attribute that I am missing for when publishing to gitlab.
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: create-react-app-template
title: Create React App Template
description: Create a new React website project
tags:
- react
- cra
spec:
owner: web#example.com
type: website
parameters:
- title: Provide some simple information
required:
- component_id
- owner
properties:
component_id:
title: Name
type: string
description: Unique name of the component
ui:field: EntityNamePicker
description:
title: Description
type: string
description: Help others understand what this website is for.
owner:
title: Owner
type: string
description: Owner of the component
ui:field: OwnerPicker
ui:options:
allowedKinds:
- Group
- title: Choose a location
required:
- repoUrl
properties:
repoUrl:
title: Repository Location
type: string
ui:field: RepoUrlPicker
ui:options:
allowedHosts:
- gitlab.example.com
steps:
- id: template
name: Fetch Skeleton + Template
action: fetch:template
input:
url: ./skeleton
copyWithoutRender:
- .github/workflows/*
values:
component_id: ${{ parameters.component_id }}
description: ${{ parameters.description }}
destination: ${{ parameters.repoUrl | parseRepoUrl }}
owner: ${{ parameters.owner }}
- id: publish
name: Publish
action: publish:gitlab
input:
allowedHosts:
- gitlab.example.com
description: This is ${{ parameters.component_id }}
repoUrl: ${{ parameters.repoUrl }}
title: Creating catalog-info.yaml ${{ parameters.name }} for backstage
- id: register
name: Register
action: catalog:register
input:
repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
catalogInfoPath: "/catalog-info.yaml"
output:
links:
- title: Repository
url: ${{ steps.publish.output.remoteUrl }}
- title: Open in catalog
icon: catalog
entityRef: ${{ steps.register.output.entityRef }}
When I want to go through the template of the Create React App it creates a
Repo Url -> gitlab.example.com?owner=maxbojorquez&repo=template

Swagger UI not showing operations with same Path but different HTTP method

For example I have 2 API operations:
GET v1/people/{id}
POST v1/people/{id}
Only one of these operations is shown in my Swagger UI API docs but I want both of them displayed. I have many examples where this is the case. In the Swagger documentation it states:
"Swagger defines a unique operation as a combination of a path and an HTTP method."
This would make me think what I want to do is possible as they are uniquely identified by the HTTP method.
If I change the path parameter for one in my swagger.yaml file they will both show.
eg:
GET v1/people/{personid}
POST v1/people/{id}
But I would rather keep them all standard otherwise my API docs will appear messy.
I am using swagger-ui-express 4.1.4.
/v1/people/{id}:
get:
summary: Get people.
security:
- cookieAuth: []
tags:
- People
parameters:
- in: path
name: id
required: true
schema:
type : integer
example: 123
responses:
'200':
description: OK
/v1/people/{id}:
post:
summary: Get people.
security:
- cookieAuth: []
tags:
- People
parameters:
- in: path
name: id
required: true
schema:
type : integer
example: 123
responses:
'200':
description: OK
Thanks for your help.
You can try same path with different method: https://swagger.io/docs/specification/paths-and-operations/.
paths:
/users/{id}:
summary: Represents a user
description: >
This resource represents an individual user in the system.
Each user is identified by a numeric `id`.
get:
...
patch:
...
delete:
...
In your example:
/v1/people/{id}:
get:
summary: Get people.
security:
- cookieAuth: []
tags:
- People
parameters:
- in: path
name: id
required: true
schema:
type : integer
example: 123
responses:
'200':
description: OK
post:
summary: Get people.
security:
- cookieAuth: []
tags:
- People
parameters:
- in: path
name: id
required: true
schema:
type : integer
example: 123
responses:
'200':
description: OK

OpenApi 3.0.2. Spec-file does not have router property

I'm trying to build an API using OpenApi 3.0.2 for active documentation. I've managed to build a validated spec-file, and if I take out all of the OpenApi "stuff" from the API itself, all of the routes work properly, and I have no errors (unless I've managed to change something vital while attempting to solve this problem).
Additionally, my controllers do in fact have the generic controller names that this error suggests I use, so my initial thought was that it's having trouble finding my controllers. However, when I used Swagger 2.0 (before rebuilding it with 3.0), I didn't have this problem.
All of my controllers are structured similarly, and when I changed the order of the controllers (path '/users' first), I retrieved the same error ('users' swapped out for 'garments' in the error log).
That said, I feel that there must be something I'm doing wrong in my "bringing together" of the functioning API and the valid spec-file.
I've been looking for a solution to this problem for a while now, but I have found nothing. If this question has been asked and answered before, I apologize; please redirect me. This is my first StackOverflow question, so please be gentle. If I have missed any information important to the question, please let me know.
Error:
outfittr | 2019-01-21T13:51:37.150Z info: Valid specification file
outfittr | 2019-01-21T13:51:37.162Z info: Specification file dereferenced
outfittr | 2019-01-21T13:51:37.210Z info: No localhost or relative server found in spec file, added for testing in Swagger UI
outfittr | 2019-01-21T13:51:37.210Z debug: Register: GET - /garments
outfittr | 2019-01-21T13:51:37.211Z debug: GET - /garments
outfittr | 2019-01-21T13:51:37.212Z debug: Spec-file does not have router property -> try generic controller name: garmentsController
outfittr | 2019-01-21T13:51:37.212Z debug: Controller with generic controller name wasn't found either -> try Default one
outfittr | 2019-01-21T13:51:37.212Z error: There is no controller for GET - /garments
outfittr exited with code 0
openapi.yaml:
openapi: 3.0.2
info:
version: "1.0.0"
title: Outfittr API
paths:
/swagger:
x-swagger-pipe: swagger_raw
####################################### Garments ##############################################
/garments:
x-router-controller: garmentsController
get:
description: Returns an array of garments.
operationId: indexGarments
responses:
"200":
$ref: '#/components/schemas/Garment'
default:
$ref: "#/components/schemas/ErrorResponse"
post:
summary: Creates a new garment
operationId: newGarment
description: Adds garment to the system
responses:
'200':
$ref: '#/components/schemas/Garment'
default:
$ref: "#/components/schemas/ErrorResponse"
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Garment'
description: User that was created.
/garments/{_id}:
x-router-controller: garmentsController
get:
description: Returns one garment
operationId: viewGarment
parameters:
- in: path
name: _id
schema:
type: string
required: true
description: Numeric ID of the user to get
responses:
"200":
$ref: '#/components/schemas/Garment'
default:
$ref: "#/components/schemas/ErrorResponse"
######################################## Users ################################################
/users:
x-router-controller: usersController
get:
description: Returns an array of users.
operationId: indexUsers
responses:
"200":
$ref: '#/components/schemas/User'
default:
$ref: "#/components/schemas/ErrorResponse"
post:
summary: Creates a new user
operationId: newUser
description: Adds user to the system
responses:
'200':
$ref: '#/components/schemas/User'
default:
$ref: "#/components/schemas/ErrorResponse"
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: User that was created.
/users/{_id}:
x-router-controller: usersController
get:
description: Returns one user
operationId: viewUser
parameters:
- in: path
name: _id
schema:
type: string
required: true
description: Numeric ID of the user to get
responses:
"200":
$ref: '#/components/schemas/User'
default:
$ref: "#/components/schemas/ErrorResponse"
####################################### Wardrobe ##############################################
/wardrobe:
x-router-controller: wardrobeController
get:
description: Returns an array of garments in the user's wardrobe.
operationId: indexWardrobeItems
responses:
"200":
$ref: '#/components/schemas/WardrobeItem'
default:
$ref: "#/components/schemas/ErrorResponse"
post:
summary: Creates a new wardrobe item
operationId: newWardrobeItem
description: Adds garment to the user's wardrobe in the system
responses:
'200':
$ref: '#/components/schemas/WardrobeItem'
default:
$ref: "#/components/schemas/ErrorResponse"
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/WardrobeItem'
description: User that was created.
/wardrobeItem/{_id}:
x-router-controller: wardrobeController
get:
description: Returns one wardrobe item
operationId: viewWardrobeItem
parameters:
- in: path
name: _id
schema:
type: string
required: true
description: Numeric ID of the user to get
responses:
"200":
$ref: '#/components/schemas/WardrobeItem'
default:
$ref: "#/components/schemas/ErrorResponse"
###################################### Components #############################################
servers:
- url: outfittr.net
- url: localhost:3000
components:
schemas:
User:
type: object
required:
- _id
- email
- username
- password
properties:
_id:
type: string
description: unique ID given by Mongo.
firstName:
type: string
description: First name of the user.
lastName:
type: string
description: Last name of the user.
email:
type: string
description: User's email address.
username:
type: string
description: User's username (for login)
password:
type: string
description: User's password (for login).
create_date:
type: string
description: date that the user joined.
__v:
type: integer
description: I have no idea.
Garment:
type: object
required:
- _id
- type
- imageLink
properties:
_id:
type: string
description: unique ID given by Mongo.
type:
type: string
description: type of garment
imageLink:
type: string
description: primary color of garment
__v:
type: integer
description: I have no idea.
WardrobeItem:
type: object
required:
- _id
- owner_id
- garment_id
properties:
_id:
type: string
description: unique ID given by Mongo.
unavailable:
type: boolean
description: Is the wardrobe item dirty, loaned out, or otherwise unavailable?
owner_id:
type: string
description: foreign key linking this wardrobe item to its owner.
garment_id:
type: string
description: foreign key linking this wadrobe item to the garment it is.
torn:
type: boolean
description: Is the wardrobe item torn?
reserveDate:
type: string
description: Optional - a date for which this wardrobe item must be worn
reserveTilDate:
type: string
description: Optional - a date after which the wardrobe item cannot be worn until the reserveDate.
__v:
type: integer
description: I have no idea.
ErrorResponse:
required:
- message
properties:
message:
type: string
Any help is vastly appreciated.
I'll answer this even if it's late because I have had this same problem and looked for a long time the solution. If someone else happens to have any reference on how to fix it.
When you set the controllers parameter in oas-tools:
OasTools.configure({
controllers: `${__dirname}/controllers`,
...
});
The default mapping that oas-tools makes to load the files is endpoint+Controller.js, in your case oas-tools would look for the export function indexGarments in .../controllers/garmentsController.js
Another example would be for the case /garments/{_ id}, the name of the controller file should be garments_idController.js
Using x-router-controller
If you want to use the parameter x-router-controller you have to put it inside the method:
...
/garments:
get:
x-router-controller: garmentsController
operationId: indexGarments
description: Returns an array of garments.
responses:
But be careful because it also modifies the value of the parameter (I do not know if this is a bug or because the name of the files has that requirement), for example, if you configure x-router-controller with the value garments.resource the file to be searched will be .../controllers/garmentsresource.js
In case you set the x-router-controller parameter and the file is not found, this error will be thrown:
info: Valid specification file
info: Specification file dereferenced
debug: Register: GET - /health
debug: GET - /health
debug: OAS-doc has x-router-controller property
error: undefined
For OAS3 you may try this:
paths:
/users:
get:
tags:
- User
x-openapi-router-controller: usersController
description: Returns an array of users.
operationId: indexUsers
responses:
"200":
$ref: '#/components/schemas/User'

Swagger Codegen - Unexpected missing property for name response

I am trying to generate node.js-server stub using codegen. I have downloaded the swagger-codegen-cli-2.3.1.jar file and am trying to generate the code using cli command.
However, it is failing with the following error message:
[main] ERROR io.swagger.codegen.DefaultCodegen - unexpected missing property for name response
[main] WARN io.swagger.codegen.DefaultCodegen - skipping invalid array property {
"baseName" : "response",
"getter" : "getResponse",
....
"isReadOnly" : false,
"vendorExtensions" : { },
"hasValidation" : false,
"isXmlAttribute" : false,
"isXmlWrapped" : false
}
[main] ERROR io.swagger.codegen.DefaultCodegen - unexpected missing property for name response
Exception in thread "main" java.lang.RuntimeException: Could not process operation:
Tag: Tag {
name: messages
description: Messages for blue instance
externalDocs: null
extensions:{}}
Operation: listMessages
Resource: get /instances/{instanceId}/messages
Definitions: {message-common=io.swagger.models.ModelImpl#e68ed4e0, Error Response=io.swagger.models.ModelImpl#7bcf5e6c}
Exception: null
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:932)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:808)
at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:431)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:746)
at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.NullPointerException
... 5 more
Here is an excerpt from my swagger definitions file.
I did adding/removing x-swagger-router-controller attribute, but that did not help either.
swagger: '2.0'
info:
title: Messages API
version: '1.0'
description: |-
Call used to get messages
host: 'localhost:8080'
paths:
'/instances/{instanceId}/messages':
get:
summary: Get all messages
operationId: listMessages
responses:
'200':
description: 'Success Response'
schema:
type: array
items:
title: Message Output
description: The properties that are included
allOf:
- type: object
properties:
id:
type: string
- title: Message Common
description: The properties that are shared
type: object
properties:
message:
type: string
description: Operation the system must do
details:
type: string
description: 'Textual data'
required:
- message
- details
'401':
description: Unauthorized requests
schema:
type: object
title: Error Response
description: Standard error message.
properties:
errors:
type: array
items:
type: object
properties:
code:
type: string
description: Human readable category
message:
type: string
description: Detailed error message
required:
- code
- message
required:
- errors
'500':
description: Response for other issues
schema:
type: object
title: Error Response
description: Standard error message.
properties:
errors:
type: array
items:
type: object
properties:
code:
type: string
description: Human readable category
message:
type: string
description: Detailed error message
required:
- code
- message
required:
- errors
description: 'Call used to get messages, notices, and/or instructions from E&E system for the product to take. '
parameters:
- name: Digest
in: header
type: string
description: The digest for the body being passed
tags:
- messages
parameters:
- name: instanceId
in: path
type: string
required: true
description: The specific instance for which the message is relevant
basePath: /v1
schemes:
- http
consumes:
- application/json
produces:
- application/json
tags:
- name: messages
description: Messages for instance
Please help. Not sure what I am missing here.
It looks like the error is caused by inline models in responses. While this is perfectly valid, it might be that Swagger Codegen does not support this. You can open an issue in the Swagger Codegen repository.
Try putting the model definitions in the global definitions section, so that your responses section looks like this:
responses:
'200':
description: 'Success Response'
schema:
type: array
items:
$ref: '#/definitions/Message'
'401':
description: Unauthorized requests
schema:
$ref: '#/definitions/Error'
'500':
description: Response for other issues
schema:
$ref: '#/definitions/Error'

Swagger generator doesn't recognize controller

I have this yaml file:
---
swagger: "2.0"
info:
version: 0.1.0
title: "My API"
host: localhost:3000
basePath: /api
schemes:
- http
paths:
/weather:
get:
x-swagger-router-controller: "weatherController"
description: "Returns current weather in the specified city to the caller"
operationId: getWeather
parameters:
- name: city
in: query
description: "The city you want weather for in the form city,state,country"
required: true
type: "string"
When I run swagger-codegen-cli, generates /api/Default.js and /api/DefaultService.js , but no /api/weatherController.js.
I've tried also with this:
---
swagger: "2.0"
info:
version: 0.1.0
title: "My API"
host: localhost:3000
basePath: /api
schemes:
- http
paths:
/weather:
x-swagger-router-controller: "weatherController"
get:
description: "Returns current weather in the specified city to the caller"
operationId: getWeather
parameters:
- name: city
in: query
description: "The city you want weather for in the form city,state,country"
required: true
type: "string"
And I run the generator with this command:
java -jar swagger-codegen-cli.jar generate -l nodejs-server -o output -i api.yaml
How can I do this?
I think that's a bug, it would be great if you could file that on the swagger-codegen project. But as a work around, consider adding a tag:
/weather:
x-swagger-router-controller: "weatherController"
get:
tags:
- weatherController
description: "Returns current weather in the specified city to the caller"
operationId: getWeather
parameters:
- name: city
in: query
description: "The city you want weather for in the form city,state,country"
required: true
type: "string"

Resources