Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    limitedAtonement
    @limitedAtonement
    Runs instantaneously ;-)
    Yeah, I was pretty dry. I thought about giving more clues...
    Alvaro Cabrera Durán
    @pateketrueke
    what do you need to solve now?
    limitedAtonement
    @limitedAtonement
    I'm not even sure.
    It's working great. Now I need to decide what type of data I need to generate.
    The project is JUST getting started.
    Alvaro Cabrera Durán
    @pateketrueke
    that's the real problem imho
    limitedAtonement
    @limitedAtonement
    I don't even know what kind of information we will be expecting from the REST service.
    Alvaro Cabrera Durán
    @pateketrueke
    always deciding what to do then...
    limitedAtonement
    @limitedAtonement
    for sure!
    Alvaro Cabrera Durán
    @pateketrueke
    that job is for your own? for someone else?
    limitedAtonement
    @limitedAtonement
    Me, collaborating with another.
    The "monkey that turns coffee into code" part is wrapping up. Now it's time for some design decisions.
    Alvaro Cabrera Durán
    @pateketrueke
    designing is nice, anything I can help you on json-schema/regexp just ask me
    limitedAtonement
    @limitedAtonement
    Sure will. You're super-helpful!
    Todd Viegut
    @tviegut
    Hey Alvaro. I just was going to check in quick. Later yesterday after we'd sorted out the invalid regex (for the date/time pattern)...I went to retest using the corrected pattern. I realized I still get the original error that we first identified: "Cannot read property 'prototype' of undefined". Just to clarify (now that we know the regex is correct) that this looks to be a known regression bug correct? ...and probably addressed in rc18 (?)
    ...on a side note. I also tested with an ultra simple regex and same outcome (did this just to make sure)
    Alvaro Cabrera Durán
    @pateketrueke
    ^ sure, seems like a regression; probably patched it on develop, but not yet released
    Todd Viegut
    @tviegut
    Gotcha Alvaro...thanks for confirming. Just was trying to see if it had appeared on the radar. :)
    Alex Marion
    @alexmarion

    Hi all, I have the following schema

    {
      "required": [],
      "properties": {
        "Toppings": {
          "required": [],
          "properties": {
            "Lettuce": {},
            "Onions": {},
            "Tomatoes": {},
            "Pickles": {}
          },
          "minProperties": 0,
          "maxProperties": 3
        }
      }
    }

    When I set alwaysFakeOptionals the first three options are set every time (but never the fourth). This makes sense because the docs say that when alwaysFakeOptionals is true it sets optionalsProbability: 1.0 and fixedProbabilities: true. When I attempt to get some variation by turning alwaysFakeOptionals: false and setting optionalsProbability: 0.5 and fixedProbabilities: true but I this only generates the empty object. Can someone point me in the right direction to either change the options to generate a more random set or change my schema to work accordingly?

    Alvaro Cabrera Durán
    @pateketrueke
    ^ hi, the latest RC17 have issues, please use a previous one
    Alex Marion
    @alexmarion
    @pateketrueke got it, thank you. Assuming you're referring to 0.5.0-rc16?
    Alvaro Cabrera Durán
    @pateketrueke
    yes!
    Alex Marion
    @alexmarion
    Awesome! Thank you for your help and prompt response
    Nick Deis
    @nickdeis
    Hey, I just made a pull request that you guys merged. Thank you so much. I was wondering when the next published version will come out.
    Alvaro Cabrera Durán
    @pateketrueke
    soon ;)
    Michiel Borkent
    @borkdude

    Hi! Say I have a JSON schema like this:

    {
      "type": "object",
      "properties": {
        "user": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "faker": "name.findName"
            },
            "email": {
              "type": "string",
              "format": "email",
              "faker": "internet.email"
            }
          },
          "required": [
            "name",
            "email"
          ]
        }
      },
      "required": [
        "user"
      ]
    }

    How do I generate example email adresses that are based on the name? For example name + @domain.org? This is just an example, I want to know how to generate data by combining data that's been generated for other fields.

    Alvaro Cabrera Durán
    @pateketrueke
    Hi!
    the "faker": "..." can be also an object, which maps to function-call & arguments
    arguments can contain placeholders, so you can use a template there, e.g.
    {
      "type": "object",
      "properties": {
        "email": {
          "faker": { "internet.email": ["foo", "#{name}", "baz"] } 
        },
        "name": {
          "faker": "name.findName"
        }
      },
      "required": ["name", "email"]
    }
    Alvaro Cabrera Durán
    @pateketrueke
    #{...} placeholders works only at same-level, so they cannot reach other values from higher hierarchies; also only works for scalar values atm
    Michiel Borkent
    @borkdude
    thanks!
    Jacob Levernier
    @publicus
    Hello, all! I'm trying to figure out whether there's a way to tell json-schema-faker to only create a single array value, rather than a random number of array values. Is there a built-in argument for this? If not, I'm looking through the codebase for where the number of array elements is randomized, but haven't found it yet, and would be grateful for any pointers anyone here would be willing to give!
    Jacob Levernier
    @publicus
    Ah, I found it, at line 92 of src/lib/types/array.js.
    Oh, and maxItems, of course!
    Alvaro Cabrera Durán
    @pateketrueke
    yep, that :)
    Jacob Levernier
    @publicus

    Actually, I find I'm unsure how maxItems is expected to work:

    In the web UI at json-schema-faker.js.org, if I use the following as a schema:

    {
      "type": "array",
      "items": {
        "enum": [
          "red",
          "green",
          "blue",
          "yellow"
        ]
      }
    }

    and set minItems to 1 and maxItems to 1, the output often has more than 1 item, like this:

    [
      "green",
      "red",
      "red",
      "green",
      "green"
    ]

    Am I misunderstanding how that should work? I expect that it should return an array of only 1 item.

    Jacob Levernier
    @publicus
    (This happens using the library with the develop branch, too)
    Alvaro Cabrera Durán
    @pateketrueke
    hi, I tested your schema also against develop and seems to be working, e.g.
    {
      "type": "array",
      "minItems": 1,
      "maxItems": 1,
      "items": {
        "enum": [
          "red",
          "green",
          "blue",
          "yellow"
        ]
      }
    }
    it gives me exactly one element, no additional options set, just the defaults
    Alvaro Cabrera Durán
    @pateketrueke
    keywords MUST be set on the appropriate schema in order to work, if you paste the same schema on the webapp it'll work, just remember to share the whole schema in order to understand and not just few bits ;)
    Jacob Levernier
    @publicus
    @pateketrueke, thank you for taking a look! Does this mean that if minItems and maxItems is not part of the schema itself, using minItems and maxItems in the arguments passed to JSF won't have any effect?
    Alvaro Cabrera Durán
    @pateketrueke
    • minItems/maxItems are part of the schema, as they are at the same level as type
    • using minItems and maxItems in the arguments passed to JSF won't have any effect? can you show how you're using such arguments?
    Jacob Levernier
    @publicus
    Sure! From https://github.com/json-schema-faker/json-schema-faker/tree/master/docs#available-options, my understanding was that JSF could be told directly, like this:
    jsf.extend('faker', function() {
      const faker = require('faker');
      return faker;
    });
    
    jsf.option({
      minItems: 1,
      maxItems: 1
    });
    
    const dummyData = await jsf
      .resolve(
        schema,
        [], // refs,
        schemaBaseDirectory
      )
      .then(result => {
        return result;
      })
      .catch(error => {
        console.log(error.stack);
      });
    In the JSF website, alternatively, I mean not having minItems and maxItems in the schema itself, but setting those in the Options drop-down menu.
    Alvaro Cabrera Durán
    @pateketrueke
    yeah, that's confusing; having to use minItems/maxItems as options will work only as override if specified on the schema, if the schema does not use such keywords then the override won't have any effect; most time you should change your schema to fit your needs
    I mean, the schema has its "options" that are keywords, using them will work; so they are "schema options" vs "generator/library options (overrides)"
    Jacob Levernier
    @publicus
    Thank you for explaining! I appreciate you taking the time! : )