Comments (5)
Hi @rbellido-ut thanks for reporting this issue, I will look into it!
from go-jsonschema.
@rbellido-ut I can't seem to reproduce your error, but I get a different one as time
does not get imported correctly. what version of go-jsonschema are you using? Also, can you share the whole generated go file, including imports, please?
from go-jsonschema.
I investigated the matter a bit today and it seems the problem is a bit more complex than I expected, as we are dealing with a nullable reference type here, which makes implementing custom unmarshalling the value correctly a bit of a challenge. I will try to see if I can find a solution in the next days, let's see.
from go-jsonschema.
Hi,
I think I may have a related problem.
I'm operating on https://csrc.nist.gov/schema/nvd/api/2.0/cve_api_json_2.0.schema, and having invoked it as go-jsonschema -p cves /tmp/cve_api_json_2.0.schema
have ended up with this particular struct:
type CveApiJson20Schema struct {
// Format corresponds to the JSON schema field "format".
Format string `json:"format" yaml:"format" mapstructure:"format"`
// ResultsPerPage corresponds to the JSON schema field "resultsPerPage".
ResultsPerPage int `json:"resultsPerPage" yaml:"resultsPerPage" mapstructure:"resultsPerPage"`
// StartIndex corresponds to the JSON schema field "startIndex".
StartIndex int `json:"startIndex" yaml:"startIndex" mapstructure:"startIndex"`
// Timestamp corresponds to the JSON schema field "timestamp".
Timestamp time.Time `json:"timestamp" yaml:"timestamp" mapstructure:"timestamp"`
// TotalResults corresponds to the JSON schema field "totalResults".
TotalResults int `json:"totalResults" yaml:"totalResults" mapstructure:"totalResults"`
// Version corresponds to the JSON schema field "version".
Version string `json:"version" yaml:"version" mapstructure:"version"`
// NVD feed array of CVE
Vulnerabilities []CveItem `json:"vulnerabilities" yaml:"vulnerabilities" mapstructure:"vulnerabilities"`
}
A sample of what I'm trying to decode is (see https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2023-4863):
{
"resultsPerPage": 1,
"startIndex": 0,
"totalResults": 1,
"format": "NVD_CVE",
"version": "2.0",
"timestamp": "2023-11-21T09:56:39.367",
"vulnerabilities": []
}
Whilst debugging why decoding was failing, I noticed this error:
time.ParseError {Layout: "2006-01-02T15:04:05Z07:00", Value: "2023-11-20T01:00:26.840", LayoutElem: "Z07:00", ValueElem: "", Message: ""}
I've been having some fun decoding the ISO 8601 format the NVD is using (see also https://mastodon.au/@andrewpollock/111447117663929594)
I'm not actually understanding how the time format "2006-01-02T15:04:05Z07:00" is getting arrived at. I know this is the time.RFC3339 constant, but I'm not seeing how things are defaulting to this? I think if I can override this (somewhere) to be "2006-01-02T15:04:05.999" instead, I might be in business...
from go-jsonschema.
Related Issues (20)
- Handling duplicate types HOT 15
- Enum integers are generated as floats. HOT 5
- local file ref failure HOT 4
- Fails to generate schema for github-workflow HOT 3
- Go install complains on go.mod HOT 4
- `maxLength` is not working as expected according to the jsonschema docs HOT 3
- How to specify a root directory for `$ref` resolution? HOT 1
- CVE Schema: could not generate type for field "...": definition does not exist in schema: HOT 6
- feat: Use of project as package
- Nested struct support? HOT 1
- Fails to generate for Signal K, cannot generate referenced type. HOT 1
- Nullable nested object support
- Incorrect string length validation for some strings. HOT 1
- Does not generate anything for the GeoJson schema
- improve support for additionalProperties HOT 1
- Problems generating structs from schema.
- minItems wrong implementation HOT 4
- Object Properties do not generate valid Unmarshal code
- Handling of `required` properties in objects HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-jsonschema.