OpenAPITools / OpenAPITools/openapi-generator

[BUG][scala-play-server] additionalProperties settings is not working and generated code is having compilation issue

Open
#13,378 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

Generated source having compilation issue for generator 'scala-play-server'.

  1. additionalProperties - does not have any type added by default unless we specify additionalProperties=true
  2. Attribute present before additionalProperties does not ends with comma(,) at the end which leads to compilation error.
package model

import play.api.libs.json._

/**
  * A category for a pet
  * @param additionalProperties Any additional properties this model may have.
  */
@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"))
case class Category(
  id: Option[Long],
  name: Option[String]
  additionalProperties:
)


openapi-generator version

Latest master branch code

OpenAPI declaration file content or url
Generation Details

Navigate to root folder of this project and issue below command after building.

java -jar ./modules/openapi-generator-cli/target/openapi-generator-cli.jar generate --generator-name="scala-play-server" --input-spec=modules/openapi-generator/src/test/resources/3_0/petstore.yaml --output=samples/server/petstore/scala-play-server

Steps to reproduce
  1. Clone master branch
  2. Open terminal in mac
  3. issue command ./mvnw
  4. Once build is successful, try issue below command to regenerate samples - bin/generate-samples.sh
  5. Notice the samples present samples/server/petstore/scala-play-server/app/model/ and we can see above mentioned two issues.

Expected output:

package model

import play.api.libs.json._

/**
  * A category for a pet
  */

case class Category(
  id: Option[Long],
  name: Option[String]
)

object Category {
  implicit lazy val categoryJsonFormat: Format[Category] = Json.format[Category]
}



Related issues/PRs
Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Build the project with ./mvnw, then reproduce with the scala-play-server command using modules/openapi-generator/src/test/resources/3_0/petstore.yaml. Inspect the generated model under samples/server/petstore/scala-play-server/app/model/, especially Category.scala, and compare it with the expected output in the issue. Done means the generated Scala source compiles and the additionalProperties and comma handling match the expected model.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, backend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.