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.

[Regression] Swagger generates empty schemas

See original GitHub issue

I’m submitting a…

  • Regression
  • 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

All swagger schemas are empty and contain no information at all.

empty-schemas

Expected behavior

Documentation detailing the property types on schemas should be inferred from the typescript definitions as described here and here. Like so:

image

Minimal reproduction of the problem with instructions

Reproduction: https://github.com/robertmain/meal-plan/tree/update-swagger

Instructions:

  1. Download the app from the link above (the branch is important!) 1 Install the dependencies and navigate to localhost:3000/api (yeah, I know it’s a crappy URL scheme…I’m working on it)

What is the motivation / use case for changing the behavior?

Empty API documentation isn’t very useful…? 🤔

Environment

Nest version: 6.6.4

For Tooling issues:

  • Node version: 10.16.3
  • Platform: Debian Linux 9

Others:

Contents of nest-cli.json

{
  "language": "ts",
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "plugins": ["@nestjs/swagger/plugin"]
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:37 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
jeanforthewebcommented, Jan 30, 2020

@robertmain Did you solved after build through webpack?

My project already using nest build but I have same issue as you

Entire project has latest nest modules but it dosen’t work… My global version of nest/cli and typescript are same as follows’ devDependencies

Here’s my package.json I’m sorry about not being able to provide reproduction repo, it’s a company project.

Same for me. Newest Nest Version using newest cli with nest new, added the plugin to nest-cli.json and it produces empty models. I’m using docker, but I’m also copying the nest-cli.json into that container

UPDATE:

Please bury me alive, I did’nt use .dto.ts files (yet) but .type.ts files. I had to adjust the “dtoFileNameSuffix” therefore. Now it’s working for me!

3reactions
askanymarkcommented, Dec 30, 2019

I’m encountering the same issue. If I don’t add @ApiProperty() the prop will not show up in the schema.

Using version 4.1.2

I’ve downgraded back to 4.0.9, which seems to work as described in the docs for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger 3.0.0 - doesn't see schema for @RequestBody
my Rest controller looks like this: @RestController @RequestMapping("/path", produces = [MediaType.APPLICATION_JSON_VALUE]) @Validated class ...
Read more >
Components Section - Swagger
Under components , the definitions are grouped by type – schemas , parameters and so on. The following example lists the available subsections....
Read more >
NestJS: Ultimate API documentation with Swagger - Medium
The documentation is generated but you notice that if you open the “InventoryItemCreateDTO”, the schema is empty! To solve this problem, we need...
Read more >
drf-yasg - Yet another Swagger generator - Read the Docs
Generate real Swagger/OpenAPI 2.0 specifications from a Django Rest Framework ... generated Swagger schema can be automatically validated by swagger-spec- ...
Read more >
apispec - Read the Docs
from marshmallow import Schema, fields. # Create an APISpec spec = APISpec( title="Swagger Petstore", version="1.0.0", openapi_version="3.0.2",.
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