我想要:
public interface IBase
{
MyObject Property1 { get; set; }
}
public interface IBaseSub<T> : IBase
{
new T Property1 { get; set; }
}
public class MyClass : IBaseSub<YourObject>
{
public YourObject Property1 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
但这不编译.它给出了错误:
//This class must implement the interface member IBase.Property1
Run Code Online (Sandbox Code Playgroud)
任何人都可以对此有所了解吗?我认为它应该工作..
谢谢
您如何为每个子类设置默认鉴别器?
例如,采用以下模式:
components:
schemas:
Pet:
type: object
required:
- petType
properties:
petType:
type: string
discriminator:
propertyName: petType
Cat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Cat`
properties:
name:
type: string
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog`
properties:
bark:
type: string
Run Code Online (Sandbox Code Playgroud)
上述模式的代码生成器将创建一个客户端,其中的petType
值必须由程序员显式设置。为什么不能默认设置Cat
对象?petType
Cat
我尝试使用default
value 让它工作。但是,生成的代码包含隐藏的属性(子级和父级上的相同属性)。
components:
schemas:
Pet:
type: object
required:
- petType
properties:
petType:
type: string …
Run Code Online (Sandbox Code Playgroud) polymorphism swagger openapi swagger-codegen openapi-generator
我似乎无法弄清楚你将如何改变以下内容
<configuration>
<location path="hello123">
<.../>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
至
<configuration>
<location path="world321">
<.../>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
不删除第一个并添加第二个.对此的任何帮助都会很棒.
谢谢