swagger-api / swagger-api/swagger-codegen
Error extracting value of parameter's 'required' property value
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Thanks for a great project!
Description
I use custom mustache templates. I have a method in swagger described below. I replaced 2 unrelated places with .... In my template, I have a condition based on required property. In the template for all properties required is true while in swagger for displayName it is false.
Mustache template:
{{#operations}}
{{#operation}}
{{#allParams.0}}
export class {{nickname}}Request {
{{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; {{/isConstEnumParam}}
{{/allParams}}
}
{{/allParams.0}}
{{/operation}}
{{/operations}}
Swagger-codegen version
3.0.8 pured from brew
Swagger declaration file content or url
swagger: "2.0"
info:
description: ""
version: "1.0.0"
title: "Swagger Petstore"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
- name: "attachments"
paths:
/attachments:
post:
tags:
- attachments
summary: upload a file
description: Uploads a file and saves it in a datastore
operationId: uploadFile
consumes:
- multipart/form-data
security:
- {}
parameters:
- name: attachmentType
type: string
in: formData
required: true
enum: [some_val]
- name: displayName
type: string
in: formData
required: false
- name: file
in: formData
type: file
required: true
responses:
204:
$ref: '#/responses/NoContent'
responses:
NoContent:
description: >-
## 204 - No Content
responses:
...
Command line used for generation
swagger-codegen generate -i ./swagger/swagger.yaml -l typescript-angular -o ./src/app/core/web-api -t ./swagger-codegen-typescript-angular --template-engine mustache
Steps to reproduce
generate code based on attached swagger. I believe it's parsing issue and not specific for generation templates
Related issues/PRs
didn't find
Suggest a fix/enhancement
don't have suggestions
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the swagger-codegen command with the supplied Swagger YAML and custom Mustache template, then inspect the generated allParams values for displayName. The issue is resolved when the generated output reflects displayName as optional while attachmentType and file remain required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100