-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type references to camel-case interface name where an underscore interface name is used #4439
Comments
@andrueastman Thank you for the fast response. I was able to get the main branch working, and tested this with a modified TypeScript (Different issue) export interface Base_commit extends object, Parsable {
/**
* The hash property
*/
hash?: string;
/**
* The parents property
*/
parents?: BaseCommit[];
}
/**
* The common base type for both repository and snippet commits.
*/
export interface BaseCommit extends object, Parsable {
/**
* The hash property
*/
hash?: string;
/**
* The parents property
*/
parents?: BaseCommit[];
} Java (Works) /**
* The common base type for both repository and snippet commits.
*/
@jakarta.annotation.Generated("com.microsoft.kiota")
public class BaseCommit extends Object implements Parsable {
/**
* The hash property
*/
private String hash;
/**
* The parents property
*/
private java.util.List<BaseCommit> parents;
/**
* Instantiates a new {@link BaseCommit} and sets the default values.
*/
public BaseCommit() {
super();
}
...
} CSharp (Works) /// <summary>
/// The common base type for both repository and snippet commits.
/// </summary>
public class Base_commit : ObjectObject, IParsable
{
...
public List<BaseCommit>? Parents { get; set; }
#nullable restore
#else
public List<BaseCommit> Parents { get; set; }
#endif
...
}
/// <summary>
/// The common base type for both repository and snippet commits.
/// </summary>
public class BaseCommit : ObjectObject, IParsable
{
...
public List<BaseCommit>? Parents { get; set; }
#nullable restore
#else
public List<BaseCommit> Parents { get; set; }
#endif
...
} Stopped testing, I believe we can conclude this is something specific to the Go writer? Let me know if more info is needed. |
Taking a look at the examples, I would expect only one model generated for these scenarios, i.e I suspect the interface is only converted from the class for one of the Go scenarios causing the build error but the root of the error looks like its related to the note.
|
@andrueastman Appreciate the feedback! I re-checked, and there are indeed no double models generated for Java: BaseCommit.java package bitbucket/client.models;
import com.microsoft.kiota.serialization.Parsable;
import com.microsoft.kiota.serialization.ParseNode;
import com.microsoft.kiota.serialization.SerializationWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* The common base type for both repository and snippet commits.
*/
@jakarta.annotation.Generated("com.microsoft.kiota")
public class BaseCommit extends Object implements Parsable {
/**
* The hash property
*/
private String hash;
/**
* The parents property
*/
private java.util.List<BaseCommit> parents;
/**
* Instantiates a new {@link BaseCommit} and sets the default values.
*/
public BaseCommit() {
super();
}
/**
* Creates a new instance of the appropriate class based on discriminator value
* @param parseNode The parse node to use to read the discriminator value and create the object
* @return a {@link BaseCommit}
*/
@jakarta.annotation.Nonnull
public static BaseCommit createFromDiscriminatorValue(@jakarta.annotation.Nonnull final ParseNode parseNode) {
Objects.requireNonNull(parseNode);
return new BaseCommit();
}
/**
* The deserialization information for the current model
* @return a {@link Map<String, java.util.function.Consumer<ParseNode>>}
*/
@jakarta.annotation.Nonnull
public Map<String, java.util.function.Consumer<ParseNode>> getFieldDeserializers() {
final HashMap<String, java.util.function.Consumer<ParseNode>> deserializerMap = new HashMap<String, java.util.function.Consumer<ParseNode>>(super.getFieldDeserializers());
deserializerMap.put("hash", (n) -> { this.setHash(n.getStringValue()); });
deserializerMap.put("parents", (n) -> { this.setParents(n.getCollectionOfObjectValues(BaseCommit::createFromDiscriminatorValue)); });
return deserializerMap;
}
/**
* Gets the hash property value. The hash property
* @return a {@link String}
*/
@jakarta.annotation.Nullable
public String getHash() {
return this.hash;
}
/**
* Gets the parents property value. The parents property
* @return a {@link java.util.List<BaseCommit>}
*/
@jakarta.annotation.Nullable
public java.util.List<BaseCommit> getParents() {
return this.parents;
}
/**
* Serializes information the current object
* @param writer Serialization writer to use to serialize this model
*/
public void serialize(@jakarta.annotation.Nonnull final SerializationWriter writer) {
Objects.requireNonNull(writer);
super.serialize(writer);
writer.writeStringValue("hash", this.getHash());
writer.writeCollectionOfObjectValues("parents", this.getParents());
}
/**
* Sets the hash property value. The hash property
* @param value Value to set for the hash property.
*/
public void setHash(@jakarta.annotation.Nullable final String value) {
this.hash = value;
}
/**
* Sets the parents property value. The parents property
* @param value Value to set for the parents property.
*/
public void setParents(@jakarta.annotation.Nullable final java.util.List<BaseCommit> value) {
this.parents = value;
}
} |
It'd be interesting to see whether this method is the culprit. |
Thanks for the reply! I was looking at the part where this "-able" notation was created, and this seems the place :) I am happy to have a look, but I am very unfamiliar with the philosophy and code, so will likely post my findings here. Looking closer, I can see the I am not sure about the mechanics and meanings of each code entity, but could the latler "base_commit" call overwrite some already set structures of "BaseCommit"? A bit off-topic; but what is the idea behind the "-able" naming in Kiota? And what is the difference between language specific refiners and language specific writers? What are "usings" in the block code declarations? This is just a small update, will see if more can be found… |
Thanks for the additional information. This is really helpful. The fact that it runs "twice" is expected as depending on how the graph is structured, we might not get to some sections otherwise.
One convention in Go seems to be having interfaces that define single methods (or a couple at most) and use the er suffix to a verb to make it a noun (i.e. interface with Read method becomes Reader).
A refiner "tweaks" the code dom into something closer to the target language. Writers are just an implementation of the visitor design pattern for all the code element types, and they are in charge of generating the code for a given element.
Arguably a bit of a dotnetism here. They are effectively imports/references. |
@Nkmol are you still looking into this? |
Thank you very much @baywet for the detailed response! Excuse my lack of response, there has been quite an abrupt shift of time, so I cannot make any promises in the near future.
I have not confirmed this “erasing” actually happens (it was assumed as the CodeDOM contained two different code style names for the same model), and I am not entirely sure where this behaviour would be best checked. I am hoping to revisit this soon. If there are any pointers you can give me, please let me know. Thanks for the responses once again! |
Kiota version: 1.12.0
Language: Go
Issue
A generated model is referencing wrongly to a created interface:
The interface it should be referencing to:
How to reproduce:
Minimal Open API:
Command used:
Further notes
This issue does not occur when I directly use the
commit_base
in the/get
definition.The text was updated successfully, but these errors were encountered: