-
Notifications
You must be signed in to change notification settings - Fork 27
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
Prepare for ADE-1: rename tags #84
Comments
I agree with that! Btw, have you had any issue with generating Animal/Location -identifiers into code? |
Got interrupted in checking the generated model. Will try to do so later today :) |
I am seeing some other issues with the default swagger codegen using the example url scheme. (I am assuming that most people will use swagger codegen so that's what I am focusing on now.) Jotting down some notes for discussion: I fixed a few missing relative paths (this seems broken in codegen, as it used the url scheme as a base, not the file it is currently reading):
Feels like a harmless compensation for a bug somewhere else? Lets look at GET /../animals first:
From a coding point of view, these names are clumsy. Since we have divided the schema's into folders, we could create a bit cleaner naming. Wrt the Animal identifier:
and
and
Suggestions:
|
1 and 2. I can do both same time I'm doing identifier changes for animal/location/breed/trait 3. This is probably should be common decision, I'm not a big fan of using prefixes/suffixes in general, but I guess such naming is part of design decision. 4. I don't see this as a problem to use all relative references. Another solution would be to create URL Schema bundle on each merge (using actions), which will contain pre-generated JSON schema with all references and which will be used for Swagger Codegen. swagger-ui-watcher is on of the tool which can be used for that purpose. |
I made a pull request containing fixes for most of the things in that thread. Code generation into CSharp using "openapi-generator" tools gives good result (also inheritance works well). |
@alamers as now all changes are merged into master you can try to generate Java code again to see if it work better from scratch? :) On Windows system I did it with "openapi-geneator" (installed via NPM) calling (both for server side code): .NET Core 3.1: openapi-geneator generate -g aspnetcore -i url-schemes/exampleUrlScheme.json -o output Java: openapi-geneator generate -g java -i url-schemes/exampleUrlScheme.json -o output There are several things to improve, but in general looks good to me |
I just ran it from swagger again (via maven:
This still has some issues, so doesn't work 'out of the box'.
Swagger codegen trips over the duplicate declaration of member in both If I remove 'member' and the discriminator 'memberType' from icarResourceCollection it generates fine. (aside from two comparable issues with discriminators in icarIdentifierType and icarEventCoreResource.json. |
I also tried it with the Some notes:
|
@alamers seems like different tools gives different results which is not very good I suppose. I've added discriminator to get codegen apply proper inheritance from superclasses (icarEventCoreResource, IdentifierType, etc.). Without discriminator all inherited classes generates as independent having internal declarations for all properties - this is at least with generating using "openapi-generator". AllOf issue is bug/feature described here OpenAPITools/openapi-generator#3100. Main reason for this is having inline schemas with AllOf declaration. Update: |
Just checked the Java version and the generation looks ok to me. The Collection classes have the 'member' field which is just a list again:
But what I understand from the discussions in the workgroup, this (superfluous) field is due to adopting the JSON-LD Hydra syntax? Anyway, it is not much of an obstacle. |
Well, personally I would'n use any of those resource collection in my final code :) public class IcarResourceCollection<T> where T : IcarEventCoreResource {
// yes, in C# we can use auto-implemented properties :)
private List<T> Member {get; set; }
} and use it for all event resource collections on API layer. But this is something you need to implement your own generator for. I'm also agree that original ticket is solved here. |
Yes, I suppose the collection classes won't be used much, just the endpoints to collect resources, not the collections themselves. (And Java at least get's its capitalization correct... ;) ) |
I was doing some testing from a Java perspective: downloading a generated Java client from Swagger UI (Swagger codegen) based on the example url scheme. (I think this would be the most common use case, either generating it from this repo, or from an implementing party directly, as this also generates the transport client.)
I noticed that the code generated is making use of the tags (now: release-candidate-milk, ...).
This then leads to API classes like in the enclosed image: "ReleaseCandidateMilkApi". Thus, the naming of these tags is important, not just for documentation. I suggest to follow the same version rules as for the url scheme and use "ade1-milk", "ade1-registration", ...
The text was updated successfully, but these errors were encountered: