Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 19 21:17
    simonthum commented #1478
  • Jan 19 21:11
    simonthum synchronize #1478
  • Jan 19 19:44
    simonthum commented #1478
  • Jan 19 15:45
    RicoSuter commented #1478
  • Jan 18 13:00
    lahma synchronize #1484
  • Jan 18 12:39
    lahma synchronize #1484
  • Jan 17 20:52
    jposert opened #1485
  • Jan 17 18:42
    lahma review_requested #1484
  • Jan 17 18:42
    lahma ready_for_review #1484
  • Jan 17 18:37
    lahma edited #1484
  • Jan 17 18:35
    lahma opened #1484
  • Jan 17 15:35
    lahma review_requested #1483
  • Jan 17 15:35
    lahma ready_for_review #1483
  • Jan 17 15:30
    lahma opened #1483
  • Jan 17 15:06

    RicoSuter on master

    Give better message from elseif… (compare)

  • Jan 17 15:06
    RicoSuter closed #1479
  • Jan 17 12:58

    RicoSuter on master

    Remove unnecessary caching in J… (compare)

  • Jan 17 12:58
    RicoSuter closed #1482
  • Jan 17 08:42
    lahma opened #1482
  • Jan 16 13:26
    Shaddix edited #1481
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
Rico Suter
@RicoSuter
the paths are generated to be correct where the schemas are actually stored... so in your case they are in "definitions"
Sevenrip
@Sevenrip

Heya I'm generating a bunch of C# classes from a json schema, the thing is our json schema has some extra features. For the sake of an example, let's say this it's the following schema:

{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "other_name": {
      "type": "string",
      "custom_property": { "stuff": "hello", "property": "goodbye" }
    }
  }
}

What is the best approach if I want to generate an additional member to the C# class based on the data on that custom_property.
I thought about parsing the created JsonSchema object to check for the existence of custom_property in the JsonSchema.ExtensionData, grabbing the parent schema and add a new Property there.
But this all seems very hackish, is there a better way to do it?

Rico Suter
@RicoSuter
you can overwrite or change a template and render additional code
https://github.com/RicoSuter/NJsonSchema/wiki/Templates
Florian Verdonck
@nojaf
Hi all, a bit of a long shot but would anyone have an idea for my question in RicoSuter/NJsonSchema#1270
Gor Grigoryan
@gor8808

Hi guys. How I can validate JsonSchema? E.g.

{
  "type": "object",
  "required": [
    "fileI",
    "message",
    "rowNumber"
  ],
  "properties": {
    "fileId": {
      "type": "sas",
      "format": "uuid"
    },
    "message": {
      "type": "string"
    },
    "rowNumber": {
      "type": "integer",
      "format": "int32"
    }
  }
}

this is invalid schema, but when I parse it using JsonSchema.FromJsonAsync it does not trow any exceptions

Wesley
@Wesley82198552_twitter
Hi everyone, I have a non standard json schema (https://www.asyncapi.com/docs/specifications/v2.0.0) that I would like to generate c# classes from. My current understanding of NJsonSchema is that it looks at the properties directory (just under root) and then looks in the definition directory (#/definitions) for references referred to in properties and then generates classes from these. In my json file, I have a directory #/components/schemas that I want classes to be generated from. How can I direct the CSharpGenerator to look at this directory as opposed to the #/definitions directory?
nikitozeg
@nikitozeg
hi all! im not having any attributes in my JSON model, but i still want to define set of required properties in JSONschema. is that possible?
@RicoSuter
should i use ExtensionData ?