apostrophecms / apostrophecms/apostrophe

Apos3: document the need to include 'type' in the publicApiProjection and flag a missing type as a probable missing projection property.

Open
#3,626 9 comments 0 reactions 0 assignees View on GitHub
bug
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

![image](https://user-images.githubusercontent.com/25711113/149975086-d33db82c-9079-43cb-8d23-110e7bd7f725.png)

## 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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.