Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #13708
Closed
Open
Issue created Oct 16, 2022 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][Crystal] Can not generate request form body parameters with additional properties

Created by: cyangle

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

It seems like OAG can't generate below spec correctly.

I have tried below command line options:

  • With minimal options

    • docker run --rm -it -v ${PWD}:/gen --user 1000:1000 --workdir /gen/ openapitools/openapi-generator-cli:latest generate --type-mappings=Object=JSON::Any,AnyType=JSON::Any,decimal=BigDecimal -g crystal -i example_api_specs/bug_spec.yml -o /gen/local/bug --additional-properties=shardName=bug,moduleName=Bug,shardLicense=MIT,shardVersion=0.0.1,shardAuthors=cyangle,skipOperationExample=true,shardDescription=Bug
    • It generated one api file fake_api.cr but there's no models generated
    • And the request body param inline_map is missing from fake_api.cr
    • api method: def fake(id : String?, map_of_string : Hash(String, String)?, map_of_pet : Hash(String, Pet)?)
  • With --global-property skipFormModel=false

    • docker run --rm -it -v ${PWD}:/gen --user 1000:1000 --workdir /gen/ openapitools/openapi-generator-cli:latest generate  --global-property skipFormModel=false --type-mappings=Object=JSON::Any,AnyType=JSON::Any,decimal=BigDecimal -g crystal -i example_api_specs/bug_spec.yml -o /gen/local/bug --additional-properties=shardName=bug,moduleName=Bug,shardLicense=MIT,shardVersion=0.0.1,shardAuthors=cyangle,skipOperationExample=true,shardDescription=Bug
    • It generated 2 models: FakeRequest and Pet
    • FakeRequest has all request body properties
    • But the model FakeRequest is never used in the generated api file fake_api.cr
    • api method is like this: def fake(id : String?)

Maybe I'm missing some command line flags for this to work.

I found this problem while trying to improve support for form serialization in crystal generator.

@wing328

openapi-generator version

6.2.1-SNAPSHOT

OpenAPI declaration file content or url

bug_spec.yml

openapi: 3.0.0
info:
  description: >-
    This spec is mainly for testing Petstore server and contains fake endpoints,
    models. Please do not use this for any other purpose. Special characters: "
    \
  version: 1.0.0
  title: OpenAPI Petstore
  license:
    name: Apache-2.0
    url: "https://www.apache.org/licenses/LICENSE-2.0.html"
tags:
  - name: fake
paths:
  /fake:
    post:
      tags:
        - fake
      operationId: fake
      parameters:
        - name: id
          in: query
          schema:
            type: string
      requestBody:
        content:
          application/x-www-form-urlencoded:
            encoding:
              map_of_string:
                explode: true
                style: deepObject
              map_of_pets:
                explode: true
                style: deepObject
              inline_map:
                explode: true
                style: deepObject
            schema:
              type: object
              properties:
                map_of_string:
                  $ref: "#/components/schemas/map_of_string"
                map_of_pet:
                  $ref: "#/components/schemas/map_of_pet"
                inline_map:
                  type: object
                  additionalProperties:
                    type: string
      responses:
        "200":
          description: The instance started successfully
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
servers:
  - url: https://localhost:8080/{version}
    description: The local server
    variables:
      version:
        enum:
          - "v1"
          - "v2"
        default: "v2"
  - url: https://127.0.0.1/no_variable
    description: The local server without variables
components:
  schemas:
    map_of_string:
      type: object
      additionalProperties:
        type: string
    map_of_pet:
      type: object
      additionalProperties:
        $ref: "#/components/schemas/pet"
    pet:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
Generation Details

See description.

Steps to reproduce

See description.

Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking