1

次の短い YAML があります。

# Transaction Request object with minimal information that we need
  Parent:
    required:
  - a
  - b
  - c
properties:
  a:
    type: number
    format: double
  b:
    type: string
  c:
    type: string

# Full transaction
Child:
required:
  - a 
  - b
  - c
allOf:
  - $ref: "#/definitions/Parent"
properties:    
  date: 
    type: string 
    format: date-time
  state: 
    type: string 
    enum: 
      - 1
      - 2
      - 3

Swagger UI とエディターでは、これらのオブジェクトは希望どおりにChild表示abcますParent

私は期待していたでしょう:

public class Parent {

  private Double a;
  private String b;
  private String c;

  ...}

 public class Child extends Parent {

 // Superclass fields as well as:
 private Date date;
 private enum State {...};

  ...}

ただし、Parentクラスは期待どおりに見えましたが、私のChildクラスは次のもので構成されていました。

public class Child   {



@Override
public boolean equals(Object o) {
if (this == o) {
  return true;
}
if (o == null || getClass() != o.getClass()) {
  return false;
}
Child child = (Child) o;
return true;
}

... }

も欠けていextendsます。を使用するdiscriminatorと機能しますが、ポリモーフィズムはあまり必要ありません-単なる継承です。Swagger Codegen でこれを達成するにはどうすればよいですか?


関連pom.xmlエントリ:

            <plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.2.2-SNAPSHOT</version>

                <configuration>
                    <inputSpec>${project.basedir}/src/main/resources/test.yaml</inputSpec>
                    <language>jaxrs-resteasy</language>
                    <output>${project.build.directory}/generated-sources/payment</output>

                    <configOptions>
                        <sourceFolder>src/java/main</sourceFolder>
                        <dateLibrary>java8</dateLibrary>
                    </configOptions>

                    <groupId>net.product</groupId>
                    <artifactId>product_api</artifactId>
                    <modelPackage>net.product.product_api.model</modelPackage>
                    <invokerPackage>net.product.product_api</invokerPackage>
                    <apiPackage>net.product.product_api</apiPackage>
                </configuration>

                <executions>

                    <execution>
                        <id>generate-server-stubs</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                        </configuration>
                    </execution>

                </executions>

            </plugin>
4

1 に答える 1