swagger-api / swagger-api/swagger-codegen

importMappings not working I can not replace import

Open
#8,042 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

      <version>2.3.1</version>
      <executions>
        <execution>
          <id>generate-server-jar</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>generate</goal>
          </goals>
          <configuration>
            <inputSpec>${swagger-gen.yml}</inputSpec>
            <language>spring</language>
            <configOptions>
              <sourceFolder>src/gen/java</sourceFolder>
              <apiPackage>${swagger-gen.api.package}</apiPackage>
              <modelPackage>${swagger-gen.model.package}</modelPackage>
              <serializableModel>true</serializableModel>
              <useJaxbAnnotations>false</useJaxbAnnotations>
              <dateLibrary>java8-localdatetime</dateLibrary>
              <generateApiTests>false</generateApiTests>
              <generateModelTests>false</generateModelTests>
            </configOptions>
            <typeMappings>
              <typeMapping>OffsetDateTime=LocalDateTime</typeMapping>
            </typeMappings>
            <importMappings>
              <importMapping>java.time.OffsetDateTime=java.time.LocalDateTime</importMapping>
            </importMappings>

          </configuration>

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

Start with the shown Spring generator configuration and trace how typeMappings and importMappings are handled during generation. Reproduce the configuration with OffsetDateTime mapped to LocalDateTime, then verify that generated Java files import and use LocalDateTime instead of OffsetDateTime.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.