question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ApiHeader default value not working

See original GitHub issue

I’m submitting a…


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I want to set a default value to my header property(requestId) using ApiHeader decorator. So, i’ve set a value. but not showing my swagger page.

Minimal reproduction of the problem with instructions

import { applyDecorators } from '@nestjs/common';
import { ApiHeader } from '@nestjs/swagger';
import { v4 as uuidv4 } from 'uuid';

export function CommonHeaderReceiptDecorator() {
  return applyDecorators(
    ApiHeader({
      name: 'requestId',
      description: 'Definition of the requestId header A unique request ID, represented by a UUID.',
      required: true,
      allowEmptyValue: false,
      schema: {
        default: uuidv4()
      }
    }),
  );
}

Environment


Nest version: 6.14.2 
For Tooling issues:
- Node version: v13.12.0
- Platform: MAC

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
kamilmysliwieccommented, Jun 22, 2020

Fixed in 4.5.11

1reaction
therescommented, Jun 22, 2020

@kamilmysliwiec https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject default property is defined on schema object level. Please reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ApiHeader default value doesn't work · Issue #666 - GitHub
I'd like to set a default value to a @ApiHeader but it's not working. The default value is not set on the json...
Read more >
Is there a way to declare a default value when using ...
Answer detailed at the bottom. The NestJS website has documentation to [declare default values][1] when using @ApiBody(), is there a way to do ......
Read more >
Describing Parameters - Swagger
The default value is the one that the server uses if the client does not supply the parameter value in the request. The...
Read more >
Amazon API Gateway API request and response data ...
When the Accept header is not specified in the request, API Gateway assumes that its default value is application/json . In this case,...
Read more >
Swagger documentation - Flask-RESTX - Read the Docs
You can specify a default response sent without knowing the response code: ... This parameter accepts the same values as the Api.doc() decorator....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found