apostrophecms / apostrophecms/apostrophe
Apos3: document the need to include 'type' in the publicApiProjection and flag a missing type as a probable missing projection property.
- Dominant language
- JavaScript
- Stars
- 4.6k
- Forks
- 650
- Avg merge
- 19h 21m
- Merged PRs (30d)
- 23
Description
## To Reproduce
Step by step instructions to reproduce the behavior:
> 1. Create a piece-type with the given file, in the `module/presentation` folder :
```
module.exports = {
extend: '@apostrophecms/piece-type',
options: {
label: 'Présentation',
pluralLabel: 'Présentations',
publicApiProjection: {
title: 1,
body: 1,
}
},
fields: {
add: {
title: {
label: 'Titre de la sous-section de présentation',
type: 'string',
required: true
},
body: {
label: 'Corps de la présentation',
type: 'area',
options: {
widgets: {
'@apostrophecms/rich-text': {
toolbar: ['styles', 'bold', 'italic'],
styles: [
{
tag: 'p',
label: 'Paragraph (P)'
},
{
tag: 'h3',
label: 'Heading 3 (H3)'
}
]
}
}
},
required: true
},
},
group: {
homePresentationFields: {
label: 'Section Présentation',
fields: ['title', 'body']
}
}
}
};
```
> 2. Run the apostrophe server with `npm run dev`
> 3. Make an API call to `http://localhost:3001/api/v1/homePresentation`
> 4. See the warning in the console

## Expected behavior
There should not be warning in this case.
## Details
**Version of Node.js:**
Node v16.13.2. but reproduced on 12 too.
**Server Operating System:**
Reproduced on Windows, Linux, inside a Docker.
**Workaround**
Adding `type :1` to `publicApiProjection` makes the warning disapear.
Contributor guide
Research direction
Start with the piece-type configuration in module/presentation and reproduce the warning by running npm run dev, then calling the shown /api/v1/homePresentation endpoint. Review the publicApiProjection behavior and existing documentation; done means the need for type is documented and a missing type is identified as a probable missing projection property.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100