Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README with relevant information from callback.md file #276

Closed
2 tasks done
radomird opened this issue Sep 30, 2021 · 4 comments · Fixed by #280
Closed
2 tasks done

Update README with relevant information from callback.md file #276

radomird opened this issue Sep 30, 2021 · 4 comments · Fixed by #280

Comments

@radomird
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Hi,
I would like to propose a suggestion. In the Readme file there is some missing information regarding schema validation that is still relevant in the new API (and I think it should be there as it is very useful).

The missing information can be found at the end of the callback.md file, I've pasted it below for reference:

The sharedSchemaId parameter must provide a string ID and a shared schema will be added to your fastify instance so you will be able to apply the validation to your service like this:

fastify.post('/upload', {
  schema: {
    body: {
      type: 'object',
      required: ['myStringField', 'myFilenameField'],
      properties: {
        myStringField: { type: 'string' },
        myFilenameField: { type: 'array', items: 'MultipartFileType#' }
    }
  }
}, function (req, reply) {
  reply.send('done')
})

The shared schema added will be like this:

{
  type: 'object',
  properties: {
    encoding: { type: 'string' },
    filename: { type: 'string' },
    limit: { type: 'boolean' },
    mimetype: { type: 'string' }
  }
}
@Eomm
Copy link
Member

Eomm commented Sep 30, 2021

The readme contains

If you enable attachFieldsToBody and set sharedSchemaId a shared JSON Schema is added, which can be used to validate parsed multipart fields.

how could we write it clearer?

@radomird
Copy link
Contributor Author

radomird commented Oct 1, 2021

The readme contains

If you enable attachFieldsToBody and set sharedSchemaId a shared JSON Schema is added, which can be used to validate parsed multipart fields.

how could we write it clearer?

That part is really clear, but the information that I quoted from callback.md file is actually missing from the readme.

@mcollina
Copy link
Member

mcollina commented Oct 1, 2021

Would you like to send a PR?

@radomird
Copy link
Contributor Author

radomird commented Oct 4, 2021

@mcollina Sure, will do that.

@Eomm Eomm closed this as completed in #280 Oct 4, 2021
Eomm added a commit that referenced this issue Oct 4, 2021
…280)

* Updated README.md with relevant information about the sharedSchemaId. #276

* Improve docs: added more details on field conversion [#277]

* Fixed typo

* Added an example for the non-file field validation

* Apply suggestions from code review

Minor styling changes on the text.

Co-authored-by: Manuel Spigolon <behemoth89@gmail.com>

* Minor wording update

Co-authored-by: Manuel Spigolon <behemoth89@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants