loopbackio / loopbackio/loopback-next

Define a required parameter using a sugar API

Aperta
#1,940 8 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

developer-experience feature good first issue Hacktoberfest REST
Lingua principale
TypeScript
Stelle
5.1k
Fork
1.1k
Merge medio
2g 21h
PR unite (30g)
27

Descrizione

At the moment, it is not possible to use @param shortcuts like @param.query.string to define a required parameter.

One has to use @param directly (but don't have to specify the type since LB4 can infer the type from TypeScript metadata). For example:

@param({name: 'format', in: 'query', required: true}) format?: string

Ideally, I would like LB4 to provide the following syntax for annotating parameters as required:

@param.query.string('format', {required: true}) format?: string

Acceptance criteria

  • Modify all @param.SOURCE.TYPE() shortcuts (and possibly other similar shortucts) to accept a new optional argument of type Partial<ParameterObject> and use the provided properties to enhance (or amend) the spec generated by the decorator.
  • Modify @param.array() in a similar way, the new optional argument will be the fourth arg.
  • Modify @param.query.object() similarly, the new optional argument will be the third arg.
  • Verify that the API documentation is able to pick up the changes

🎆 Hacktoberfest 2020

Greetings 👋 to all Hacktoberfest 2020 participants!

Here are few tips 👀 to make your start easier, see also #6456:

  • Before you start working on this issue, please leave a comment to let others know.
  • If you are new to GitHub pull requests, then you can learn about the process in Submitting a pull request to LoopBack 4.
  • If this is your first contribution to LoopBack, then please take a look at our Developer guide
  • Feel free to ask for help in #loopback-contributors channel, you can join our Slack workspace here.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia individuando le implementazioni TypeScript delle scorciatoie @param.SOURCE.TYPE(), @param.array() e @param.query.object(), quindi esamina come le relative specifiche ParameterObject generate vengono esposte nella documentazione API. Aggiorna le scorciatoie in modo che accettino le proprietà opzionali indicate e verifica che la documentazione le rifletta, inclusi i parametri obbligatori.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
openapi, typescript
Ambito
api, documentation
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.