Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 01 12:44
    jeremyVignelles commented #1289
  • Dec 01 12:29
    jacobpovar commented #1289
  • Dec 01 12:22
    jacobpovar synchronize #1289
  • Dec 01 12:13
    jacobpovar synchronize #1289
  • Dec 01 11:04
    jacobpovar synchronize #1289
  • Dec 01 10:42
    jeremyVignelles commented #1289
  • Dec 01 10:36
    RicoSuter commented #1289
  • Dec 01 10:36
    RicoSuter commented #1289
  • Dec 01 10:34
    RicoSuter commented #1289
  • Nov 30 19:04
    GersonDias edited #1290
  • Nov 30 18:54
    GersonDias edited #1290
  • Nov 30 18:52
    GersonDias edited #1290
  • Nov 30 18:46
    GersonDias opened #1290
  • Nov 30 13:22
    jacobpovar opened #1289
  • Nov 27 13:08
    chiro300 edited #1288
  • Nov 27 13:08
    chiro300 opened #1288
  • Nov 26 20:46
    RicoSuter commented #1287
  • Nov 26 20:46

    RicoSuter on master

    fix(NJsonSchema.CodeGeneration.… (compare)

  • Nov 26 20:46
    RicoSuter closed #1287
  • Nov 26 11:25
    rars opened #1287
Rico Suter
@RicoSuter
But is this the only problem?
Jérémy VIGNELLES
@jeremyVignelles
I'll have a look anyway
I think that #nullable enable should be enough
but how do we manage cases where nullables are not enabled in nswag's config but enabled at the project level ?
do we consider it a bad configuration ?
Or is it implicitely #nullable disable since it is a generated file ?
Rico Suter
@RicoSuter
Is it even a problem when the project is enabled and nswag not (it has no nrt)?
How does it recognize a generated file and why does that even matter?
Jérémy VIGNELLES
@jeremyVignelles

Is it even a problem when the project is enabled and nswag not (it has no nrt)?

If the file is included in the project with nullable enable, all properties would be considered mandatory, unless there is a special treatment of the auto generated files (it seems there is)

Rico Suter
@RicoSuter
I’d “ignore” the case enabled in proj + disabled in cfg
Jérémy VIGNELLES
@jeremyVignelles
yes, because either it's already handled, or it's bad configuration
Rico Suter
@RicoSuter
As you usually have a client proj just for the generated code
Jérémy VIGNELLES
@jeremyVignelles
I do have some helpers along with the generated code in one of my projects
I'll try to put #nullable enable if the configuration says so
Jérémy VIGNELLES
@jeremyVignelles
@RicoSuter : I've added the line conditionally in NJS, do you want me to write some unit tests ?
Jérémy VIGNELLES
@jeremyVignelles
=> #1201
Jérémy VIGNELLES
@jeremyVignelles
Seems more complex than anticipated, now I have a bunch of other warnings in the generated file
(I added #nullable enable manually in the file since I couldn't generate a NSwag.MSBuild)
Rico Suter
@RicoSuter
Nswag msbuild is not part of the PR ci build as it is more complex and not migrated yet
Jérémy VIGNELLES
@jeremyVignelles
ok
for example, the code for ApiException needs to be annotated to allow innerException to be null
Rico Suter
@RicoSuter
Yep i think we should first manually “fix” the stuff and then do a release
Jérémy VIGNELLES
@jeremyVignelles
I'd like to be able to test that properly, but I don't know where to start

return default(ApiModel);

Also warns here

Rico Suter
@RicoSuter
You mean testing fully with nswag?
Jérémy VIGNELLES
@jeremyVignelles
yes, to not publish things blindly and make sure that the generated file compiles
Rico Suter
@RicoSuter
I think NSwag.Min.sln has a CLI project, right?
Jérémy VIGNELLES
@jeremyVignelles
oh, there is a Min.sln? That's why it took long to open :D
Rico Suter
@RicoSuter
You can use DNT to switch njs pkg refs to project refs and then fully test it (nswag.consolecore can run nswag.json configs)
Jérémy VIGNELLES
@jeremyVignelles
lot of new things in your last sentence ^^ Don't know about DNT
Jérémy VIGNELLES
@jeremyVignelles
nice :thumbsup:
I'll have a look at it
Jérémy VIGNELLES
@jeremyVignelles
should I try to change things in the same PR or is it another one ?
either I need to rename the PR, or I need to create other PRs, you tell me
Rico Suter
@RicoSuter
I’d use one pr in nswag and one in njs, then we merge and release the njs pr and update the other one with new nugets (+ switch back with dnt)
Its a bit tedious because its in two solutions
Jérémy VIGNELLES
@jeremyVignelles
I'm used to that, but dnt indeed simplifies the process, I'm considering adopting it on my work's solutions
Veikko Eeva
@veikkoeeva

Would anyone have off-hand example on how to solve external references? I'm currently looking at https://github.com/w3c/did-spec-registries/blob/master/schemas/didDocument/didDocument.json#L86 cases and while the files are there, they are not resolved directly. I tried something like

Func<JsonSchema, JsonReferenceResolver> referenceResolverFactory = rootObject =>
            {
                JsonSchemaResolver schemaResolver = new JsonSchemaResolver(rootObject, new JsonSchemaGeneratorSettings());
                JsonReferenceResolver jsonReferenceResolver = new JsonReferenceResolver(schemaResolver);

                var schema = JsonSchema.FromFileAsync(@"C:\<path>\publicKey.json").Result;
                schemaResolver.AppendSchema(schema, "did-core.publicKey");

                var schema2 = JsonSchema.FromFileAsync(@"C:\<path>\Ed25519VerificationKey2018.json").Result;
                schemaResolver.AppendSchema(schema2, "did-core.publicKey.Ed25519VerificationKey2018");

                return jsonReferenceResolver;
            };

but so long in vain. What seem to work a bit (the generated code doesn't compile) is that if I download the files and remove the .json extension.

Veikko Eeva
@veikkoeeva
Veikko Eeva
@veikkoeeva
Though looking at these definitions, any generetor generated likely needs to be enhanced manually. :)
Erik J. Hoeksma
@las3r

Hi all, I'm trying to generate both ts and c# classes from multiple jsonschema files. The idea is to use CI/CD to generate 'shared libraries' to use with typescript and .NET core projects. I think I'm right in thinking that I need an MSBuild PrepareForBuild step. Everything after that is a bit foggy. Basically I want it to generate a fitting c# class for "every" json schema file (I have many).

It seems that

    <Exec Command="$(NSwagExe_Core30) run nswag.json /variables:Configuration=$(Configuration)" />

Will build the actual assembly with the .net classes based on the (hardcoded) jsonschema in the .nswag file. How do I make it "use" all the loose json schema files in my working folder, rather than a hardcoded schema in the configuration file?

(note, the geneation of c# is not the goal, the goal is a nuget package that I can distribute)
Erik J. Hoeksma
@las3r
It seems that the configuration file will only accept a single schema, and not e.g. a glob pattern for a folder to use with json schema files? Am i gonig about this right / wrong way?
Rico Suter
@RicoSuter
Exactly, you’d first need to manually merge them into one with multiple definitions keys
pavi-s822
@pavi-s822
Can I create NJsonSchema project?
Henrik Justegård
@Justegard
@veikkoeeva json-schema-ref-parser is a tool you could use for dereferencing schemas.
Henrik Justegård
@Justegard
Hi, I have been trying to validate against a schema that contains the "dependencies" keyword using njsonschema. However support for that keyword doesn't seem to be implemented, is that correct?
Rostislav Kirillov
@Rast1234
hi. how do i customize $ref paths when serializing a schema? i tried to set DocumentPath on root schema and on added ones but nothing happened. currently all $refs look like "$ref": "#/definitions/ClassName" when i need #/components/schemas/ClassName