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

Generated client not compiled when x-go-name is specified #2892

Closed
asv opened this issue Jan 31, 2023 · 0 comments · Fixed by #2893
Closed

Generated client not compiled when x-go-name is specified #2892

asv opened this issue Jan 31, 2023 · 0 comments · Fixed by #2893

Comments

@asv
Copy link
Contributor

asv commented Jan 31, 2023

Problem statement

When using abbreviations (in my case PDF) and x-go-name, non-compiled code is generated.

Example: a parameter named pdf_extraction_mode (translated to a literal PdfExtractionMode) and its x-go-name PDFExtractionMode.

The code in the *Params structure is generated correctly (the name is the same as in x-go-name), however, in the generated SetDefaults code, the PdfExtractionMode literal is substituted, which breaks the compilation.

$ go build ./client/                                                                    
client/operations/extract_pdf_parameters.go:94:3: unknown field 'PdfExtractionMode' in struct literal of type ExtractPdfParams

Swagger specification

swagger: "2.0"
info:
  title: Sample API
  description: API description in Markdown.
  version: 1.0.0
host: api.example.com
basePath: /v1
schemes:
  - https
paths:
  /pdf:
    get:
      operationId: ExtractPdf
      parameters:
        - name: pdf_extraction_mode
          type: string
          enum:
            - fast
            - full
          x-go-name: PDFExtractionMode
          default: fast
          description: Lorem ipsum
          in: formData
      responses:
        200:
          description: OK

Steps to reproduce

  1. swagger generate client -q -A buggygen --spec example.yaml
  2. trying to build this code (go build ./client)

Environment

swagger version: 0.30.3
go version: 1.19
OS: MacOS Catalina

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.

1 participant