OpenAPI 生成器(jaxrs-spec)为 AllOf 枚举对象生成单独的类

问题描述 投票:0回答:0

我创建了一个包含带有枚举值的对象的规范。有些方法应该支持所有枚举值,因此我想只是将枚举对象作为 allOf 引用,但这似乎不起作用。

在下面的示例中,EnumObject 类不包含任何值,而 EnumObjectA 和 EnumObjectB 按预期工作。

openapi: 3.0.3
info:
    title: Test spec for StackOverflow
    version: 1.0.0
paths:
    /status:
        get:
            tags:
                - Test
            summary: Test summary
            description: 'Test description'
            operationId: testOperationId
            responses:
                '200':
                    description: Successful operation
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/TestResponse'
components:
    schemas:
        TestResponse:
            type: object
            properties:
                stringId:
                    type: string
                enumObject:
                    $ref: '#/components/schemas/EnumObject'
        EnumObject:
            allOf:
                - $ref: '#/components/schemas/EnumObjectA'
                - $ref: '#/components/schemas/EnumObjectB'
        EnumObjectA:
            type: string
            description: Enum object A
            enum:
                - VALUE_A1
                - VALUE_A2
        EnumObjectB:
            type: string
            description: Enum object B
            enum:
                - VALUE_B1
                - VALUE_B2
                - VALUE_B3

我在

openapi-generator-maven-plugin
中使用以下配置。如果不支持此功能或者我错过了什么?

<configuration>
    <inputSpec>${project.basedir}/src/main/resources/openapi/rest.yaml</inputSpec>
    <generatorName>jaxrs-spec</generatorName>

    <configOptions>
        <dateLibrary>java8</dateLibrary>
        <interfaceOnly>true</interfaceOnly>
        <useTags>true</useTags>
    </configOptions>

    <generateApiTests>false</generateApiTests>
    <generateApiDocumentation>false</generateApiDocumentation>
    <generateModelTests>false</generateModelTests>
    <generateModelDocumentation>false</generateModelDocumentation>
    <generateSupportingFiles>false</generateSupportingFiles>
    <ignoreFileOverride>${project.basedir}/src/main/resources/.openapi-codegen-ignore</ignoreFileOverride>
</configuration>
java maven-plugin openapi-generator openapi-generator-maven-plugin
© www.soinside.com 2019 - 2024. All rights reserved.