Different content types in pages - bolt-cms

I'm working on a small site that just needs to have a simple CMS to edit it's content. So I started with Bolt. At the moment I have 5 pages that has a different markup, like content structure. Is it possible to do it like this? Because at the moment it doesn't work unfortunately.
My contenttypes.yml:
pages:
name: Homepage
singular_name: homepage
fields:
title:
type: text
class: large
group: content
slug:
type: slug
uses: title
header-image:
type: image
title-one:
type: text
header-text:
type: html
title-two:
type: text
text-one:
type: html
body-image-two:
type: image
title-three:
type: text
body-image-text:
type: html
title-four:
type: text
text-two:
type: html
title-five:
type: text
text-three:
type: html
template:
type: templateselect
filter: '*.twig'
taxonomy: [ groups ]
recordsperpage: 100
name: Over ons
singular_name: over-ons
fields:
title:
type: text
class: large
group: content
slug:
type: slug
uses: title
image:
type: image
title-one:
type: text
title-two:
type: text
body:
type: html
height: 300px
template:
type: templateselect
filter: '*.twig'
taxonomy: [ groups ]
recordsperpage: 100
name: Diensten
singular_name: diensten
fields:
title:
type: text
class: large
group: content
slug:
type: slug
uses: title
image:
type: image
title-one:
type: text
intro-text:
type: html
title-two:
type: text
text-two:
type: html
title-three:
type: text
text-three:
type: html
title-four:
type: text
text-four:
type: html
title-five:
type: text
text-five:
type: html
template:
type: templateselect
filter: '*.twig'
taxonomy: [ groups ]
recordsperpage: 100
name: Het proces
singular_name: het-proces
fields:
title:
type: text
class: large
group: content
slug:
type: slug
uses: title
image-one:
type: image
title-one:
type: text
intro-text:
type: html
title-two:
type: text
text-two:
type: html
image-two:
type: image
title-three:
type: text
text-three:
type: html
image-three:
type: image
title-four:
type: text
text-four:
type: html
image-four:
type: image
title-five:
type: text
text-five:
type: html
image-five:
type: image
title-six:
type: text
text-six:
type: html
image-six:
type: image
template:
type: templateselect
filter: '*.twig'
taxonomy: [ groups ]
recordsperpage: 100
name: Projecten
singular_name: projecten
fields:
title:
type: text
class: large
group: content
slug:
type: slug
uses: title
title-one:
type: text
intro-text:
type: html
title-two:
type: text
text-two:
type: html
image-two:
type: image
template:
type: templateselect
filter: '*.twig'
taxonomy: [ groups ]
recordsperpage: 100
name: Contact
singular_name: contact
fields:
title:
type: text
class: large
group: content
slug:
type: slug
uses: title
title-one:
type: text
intro-text:
type: html
template:
type: templateselect
filter: '*.twig'
taxonomy: [ groups ]
recordsperpage: 100
Any ideas on a solution?
Thanks in advance.

I would suggest to only use one contenttype "pagina's" for that. If you need to diversify them, use the templateselect (like you're doing already), and perhaps add a "template field" or two.
See here: https://docs.bolt.cm/2.2/templates/building-templates#template-specific-fields

Related

how do I validate a JSON payload in OpenAPI 3.0 with Mule 4.4 Runtime

I need to develop a Mule API ( 4.4 Runtime ) with openapi: 3.0.0
The endpoint is a POST with the following request payload :
{
"Employee": {
"Address": {
"City": "a",
"Country": "aaa"
}
}
}
Here is the relevant section of the OpenAPI 3.0 spec :
openapi: "3.0.0"
paths:
/search:
post:
tags:
- SearchUser
summary: Search for Users
operationId: getUser
requestBody:
description: User Request Object
content:
application/json:
schema:
$ref: '#/components/schemas/RequestComp'
required: true
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ResponseComp'
'400':
description: Bad request
content: {}
'404':
description: User not found
content: {}
'405':
description: Validation exception
content: {}
components:
schemas:
RequestComp:
type: object
properties:
Employee:
$ref: '#/components/schemas/EmployeeComp'
EmployeeComp:
type: object
properties:
Address:
$ref: '#/components/schemas/AddressComp'
AddressComp:
type: object
properties:
City:
type: string
required: true
nullable: false
minLength: 1
Country:
type: string
required: true
nullable: false
minLength: 1
ResponseComp:
type: object
properties:
City:
type: string
Country:
type: string
So I can validate individual elements like 'City' and 'Country' to not be null but how do I prevent following request ? ( presently its not being flagged as invalid : )
{
"Address": {
"City": "a",
"Country": "aaa"
}
}
You can define the Employee wrapper as a required property and also disallow unknown properties by adding additionalProperties: false. Note that required is not a property-level attribute, but an object-level attribute - it's a list of required properties.
components:
schemas:
RequestComp:
type: object
required: [Employee] # <-----
properties:
Employee:
$ref: '#/components/schemas/EmployeeComp'
additionalProperties: false # <-----
EmployeeComp:
type: object
properties:
Address:
$ref: '#/components/schemas/AddressComp'
additionalProperties: false # <-----
AddressComp:
type: object
required: [City, Country] # <-----
properties:
City:
type: string
# required: true # <-- remove this
nullable: false
minLength: 1
Country:
type: string
# required: true # <-- remove this
nullable: false
minLength: 1
additionalProperties: false # <-----

I want to create nested "mat-option" in "mat-select"

I'm developing a web app, and have a sample data that looks like this as a ts file:
/** Example file/folder data. */
export const files = [
{
name: 'privatec-omponents',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{
name: 'private-src',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{
name: 'private-cdk',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{ name: 'private-package.json', type: 'file', date:'11/21/2020',kind: 'json', size: '2MB' },
{ name: 'private-BUILD.bazel', type: 'file', date: '11/21/2020', kind: 'bazel', size: '2MB' },
]
},
{ name: 'private-material', type: 'folder', date: '11/21/2020', kind: 'folder', size: '--' }
]
}
]
},
{
name: 'private-angular',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{
name: 'private-packages',
type: 'folder',
date: '11/21/2020',
kind: 'folder',
size: '--',
children: [
{ name: 'private-travis.yml', type: 'file', date: '11/21/2020', kind: 'yml', size: '2MB' },
{ name: 'firebase.json', type: 'file', date: '11/21/2020', kind: 'json', size: '2MB' }
]
},
{ name: 'private-package.json', type: 'file', date: '11/21/2020', kind: 'json', size: '--' }
]
}
];
I want to show all folder names as "mat-select" to let users choose the file directory to save their files, however, currently, only parent folders are displayed.
Is there any way that I can display all folders in the "mat-option"? I also want to add padding if the folder has a parent folder?
This is how HTML looks like.
<mat-form-field>
<mat-label>Drirectry Name</mat-label>
<mat-select name="fileName" [(value)]="selectedCountry" placeholder="Country">
<mat-option *ngFor="let file of file" [value]="file.name">
{{file.name}}
</mat-option>
</mat-select>
</mat-form-field>
This is how it appears on the web.
How can I do them?
You actually want to wrap your mat-option in a mat-optgroup for any nested values
Example:
<mat-select [formControl]="pokemonControl">
<mat-option>-- None --</mat-option>
<mat-optgroup *ngFor="let group of pokemonGroups" [label]="group.name"
[disabled]="group.disabled">
<mat-option *ngFor="let pokemon of group.pokemon" [value]="pokemon.value">
{{pokemon.viewValue}}
</mat-option>
</mat-optgroup>
</mat-select>
See Select with option groups in the docs: https://material.angular.io/components/select/examples

Undefined method `gsub' for #<Hash:0x00007fed774d2a3> (NoMethodError)

I am trying to hook up my Jekyll installation with NetlifyCMS. I am using a custom theme that works fine without the CMS part, however when I integrate as per the NetflifyCMS docs I get this error.
~/.rvm/gems/ruby-2.5.1/gems/jekyll-3.4.1/lib/jekyll/collection.rb:158:in `sanitize_label': undefined method `gsub' for #<Hash:0x00007fed774d2a3
I am running this on a Mac OSX and here is my config.yml is. The relevant section is the collection section:
collections:
- name: 'docs'
output: true
label: 'Docs'
folder: '_docs/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- { label: 'Body', name: 'body', widget: 'markdown' }
- name: 'faqs'
output: false
label: 'Faqs'
folder: '_faqs/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- { label: 'Body', name: 'body', widget: 'markdown' }
- name: 'changelogs'
output: false
- name: 'blog'
output: true
label: 'Blog'
folder: '_posts/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- { label: 'Body', name: 'body', widget: 'markdown' }
Found the problem. NetlifyCMS docs weren't so clear. These collections should have been put in the ./admin/config.yml and I was putting them in the main config.yml file.

Swagger-Editor empty response in client generated in HTML

I'm doing documentation for a project. On the website everything is showing correctly in the preview, though it is showing error "Resolver error Cannot read property '0' of undefined".
When generating client in html2 response schema is blank.
UPDATE: showing full code now.
I've tried cutting one level (Entity->EntityItem->EntityResponse to Entity->EntityResponse), error stopped, HTML still not showing full data.
openapi: 3.0.0
info:
description: not working
version: "1.0.0"
title: ...
contact:
email: work#pls.com
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
#====================================================================================
paths:
/search/nip/{nip}:
get:
operationId: nip?date
parameters:
- in: path
name: nip
required: true
schema:
type: string
minLength: 10
maxLength: 10
description: "Nip"
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityResponse'
'400':
description: ...
description: ...
/search/regon/{regon}:
get:
operationId: regon?date
parameters:
- in: path
name: regon
required: true
schema:
type: string
pattern: '^\d{9}$|^\d{14}$'
description: ...
example: '364760520'
description: Regon
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityResponse'
'400':
description: ...
description: ...
/search/bank-account/{bank-account}:
get:
operationId: bank-account?date
parameters:
- in: path
name: bank-account
required: true
schema:
type: string
minLength: 26
maxLength: 26
description: ...
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityListResponse'
'400':
description: ...
description: ...
/check/nip/{nip}/bank-account/{bank-account}:
get:
operationId: checkNip
parameters:
- in: path
name: nip
required: true
schema:
type: string
minLength: 10
maxLength: 10
description: "Nip"
- in: path
name: bank-account
required: true
schema:
type: string
minLength: 26
maxLength: 26
description: Numer rachunku bankowego
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityCheckResponse'
'400':
description: ...
description: ...
/check/regon/{regon}/bank-account/{bank-account}:
get:
operationId: checkRegon
parameters:
- in: path
name: regon
required: true
schema:
type: string
pattern: '^\d{9}$|^\d{14}$'
description: numer identyfikacyjny REGON
example: '364760520'
description: Regon
- in: path
name: bank-account
required: true
schema:
type: string
minLength: 26
maxLength: 26
description: ...
- in: query
name: date
required: true
schema:
type: string
format: date
example: '2019-05-17'
responses:
'200':
description: ...
content:
application/json:
schema:
$ref: '#/components/schemas/EntityCheckResponse'
'400':
description: ...
description: ...
#====================================================================================
components:
schemas:
EntityRequestBase:
properties:
data:
type: string
format: date
example: '2019-05-17'
bank-account:
type: array
items:
type: string
minLength: 26
maxLength: 26
example: '90249000050247256316596736'
nip:
type: string
minLength: 10
maxLength: 10
example: '1111111111'
regon:
type: string
pattern: '^\d{9}$|^\d{14}$'
description: |
...
example: '364760520'
pesel:
type: string
description: |
...
minLength: 11
maxLength: 11
example: '22222222222'
required:
- data
#====================================================================================
Exception:
properties:
message:
type: string
example: 'error message'
code:
type: integer
required:
- message
- code
#====================================================================================
Person:
properties:
firstName:
type: string
example: Jan
lastName:
type: string
example: Nowak
pesel:
$ref: '#/components/schemas/EntityRequestBase/properties/pesel'
nip:
type: string
minLength: 10
maxLength: 10
example: '1111111111'
#====================================================================================
EntityPerson:
allOf:
- $ref: '#/components/schemas/Person'
- properties:
companyName:
type: string
example: 'Nazwa firmy'
#====================================================================================
EntityCheck:
properties:
accountAssigned:
type: string
example: TAK
description: |
...
requestId:
type: string
example: 'd2n10-84df1a1'
#====================================================================================
Entity:
allOf:
- properties:
name:
type: string
example: 'ABC Jan Nowak'
description: |
...
nip:
type: string
minLength: 10
maxLength: 10
example: '1111111111'
statusVat:
type: string
enum:
- C
- Z
- P
example: Z
description: |
...
regon:
type: string
pattern: '^\d{9}$|^\d{14}$'
description: |
...
example: '364760520'
pesel:
$ref: '#/components/schemas/EntityRequestBase/properties/pesel'
krs:
type: string
example: '0000636771'
maxLength: 10
minLength: 10
description: |
...
residenceAddress:
type: string
example: 'ul/ Taka a Owaka 12 01- Warszawa'
description: |
...
workingAddress:
type: string
representatives:
type: array
items:
$ref: '#/components/schemas/Person'
description: |
...
authorizedClerks:
type: array
items:
$ref: '#/components/schemas/Person'
description: |
...
partners:
type: array
items:
$ref: '#/components/schemas/EntityPerson'
description: |
...
registrationLegalDate:
type: string
format: date
example: '2018-02-21'
registrationDenialDate:
type: string
format: date
example: '2019-02-21'
description: |
...
registrationDenialBasis:
type: string
example: 'Ustawa o podatku od towarów i usług art. 96'
description: |
...
restorationDate:
type: string
format: date
example: '2019-02-21'
description: |
...
restorationBasis:
type: string
example: 'Ustawa o podatku od towarów i usług art. 96'
description: |
...
accountNumbers:
type: array
items:
type: string
minLength: 26
maxLength: 26
example: '90249000050247256316596736'
hasVirtualAccounts:
type: boolean
example: true
description: |
...
required:
- name
#====================================================================================
EntityItem:
allOf:
- properties:
subject:
$ref: '#/components/schemas/Entity'
requestId:
type: string
example: 'd2n10-84df1a1'
#====================================================================================
EntityList:
allOf:
- properties:
subjects:
type: array
items:
$ref: '#/components/schemas/Entity'
description: |
...
requestId:
type: string
example: 'd2n10-84df1a1'
#====================================================================================
EntityResponse:
allOf:
- properties:
exception:
$ref: '#/components/schemas/Exception'
result:
$ref: '#/components/schemas/EntityItem'
EntityCheckResponse:
allOf:
- properties:
exception:
$ref: '#/components/schemas/Exception'
result:
$ref: '#/components/schemas/EntityCheck'
EntityListResponse:
allOf:
- properties:
exception:
$ref: '#/components/schemas/Exception'
result:
$ref: '#/components/schemas/EntityList'
The issue seems to be caused by the ? question mark in operation IDs:
operationId: nip?date
If you remove the question mark, HTML2 docs will include response schemas.
You can file a bug report in the Swagger Codegen repository at https://github.com/swagger-api/swagger-codegen/issues.
Found the solution, it was due to the misuse of "allOf", without them error stops and HTML is generated correctly. It only made sense in "Person", all the other cases were deleted.

Following swagger specifications, how can I define json of nested objects to yaml?

I am having a problem in defining the array of objects in swagger yaml. Swagger editor is giving an error everytime I try to define the type: array part of the yaml. I defined it, but it is not right as it is giving an error.
Following is the json I am trying to define in swagger yaml.
{
"CountryCombo": {
"options": {
"option": [{
"id": "GB",
"value": "GB Great Britain"
}, {
"id": "US",
"value": "US United States"
}, {
"id": "AD",
"value": "AD Andorra, Principality of"
}]
}
}
}
I defined this json into swagger yaml like this but it is giving an error:
CountryCombo:
type: object
properties:
options:
type: object
properties:
option:
type: array
items:
- id:
type: string
description: GB
value:
type: string
description: GB Great Britain
- id:
type: string
description: US
value:
type: string
description: US United States
- id:
type: string
description: AD
value:
type: string
description: AD Andorra, Principality of
Can anyone suggest me how would I define this json in yaml following swagger specifications?
In a schema, you don't want to have the values, only the description of the values.
CountryCombo:
type: object
properties:
options:
type: object
properties:
option:
type: array
items:
type: object
properties:
id:
type: string
value:
type: string
The above answer is also right but I already implemented this in my yaml. I found that I can also define array by creating another definition.
CountryCombo:
type: object
properties:
options:
type: object
properties:
option:
type: array
items:
$ref: '#/definitions/Country_row'
Country_row:
type: object
properties:
id:
type: string
value:
type: string
The accepted answer cannot achieve the output desired the question. Swagger documentation on examples explains how to add multiple examples for an array of objects:
definitions:
ArrayOfCatalogItems:
type: array
items:
$ref: '#/definitions/CatalogItem'
example:
- id: 38
title: T-shirt
- id: 114
title: Phone
OP was actually on the right track, but made a syntactic mistake:
CountryCombo:
type: object
properties:
options:
type: object
properties:
option:
type: array
items:
- id:
type: string
value:
type: string
- id:
type: string
value:
type: string
- id:
type: string
value:
type: string
example:
- id: GB
value: GB Great Britain
- id: US
value: US United States
- id: AD
value: AD Andorra, Principles of