Skip to content
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

Use schema that doesn't come from a file #284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ptodev
Copy link

@ptodev ptodev commented Sep 19, 2024

It is sometimes useful to place the json schema in a file which may also contain other config. For example:

fields:
  not:

used:
  by:
  json_schema:

json_schema:

In the above example, we'd only need to give go-jsonschema the config which is under json_schema. The way I've been doing it so far is by making addFile a public function. Do you think this is ok?

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 73.17%. Comparing base (d963216) to head (0293bd3).
Report is 96 commits behind head on main.

Files with missing lines Patch % Lines
pkg/generator/schema_generator.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #284      +/-   ##
==========================================
- Coverage   76.58%   73.17%   -3.41%     
==========================================
  Files          24       43      +19     
  Lines        1892     2837     +945     
==========================================
+ Hits         1449     2076     +627     
- Misses        354      588     +234     
- Partials       89      173      +84     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ptodev
Copy link
Author

ptodev commented Oct 29, 2024

Hi, @omissis! Do you think such a feature would be acceptable? I am happy to polish it or to take a different approach if you would like it done differently :)

@omissis
Copy link
Owner

omissis commented Nov 3, 2024

@ptodev I am not sure I understand how the change correlates with the need you are exposing here. I would do something like this to handle your case:

yq -M '.json_schema' your_config.yaml | go-jsonschema - --package example --output /tmp/your_config_schema.go

Probably you're talking about using go-jsonschema as a library? In that case I assume you've already extracted the schema from the property in the file before calling AddFile()?

@omissis omissis self-requested a review November 3, 2024 14:38
@dehaansa
Copy link

dehaansa commented Nov 5, 2024

@ptodev I am not sure I understand how the change correlates with the need you are exposing here. I would do something like this to handle your case:

yq -M '.json_schema' your_config.yaml | go-jsonschema - --package example --output /tmp/your_config_schema.go

Probably you're talking about using go-jsonschema as a library? In that case I assume you've already extracted the schema from the property in the file before calling AddFile()?

Hi @omissis that's correct, we're looking to use go-jsonschema as a library, and passing an extracted schema from a file containing the schema and other metadata. @ptodev is out on PTO right now so I'm trying to follow up!

@omissis
Copy link
Owner

omissis commented Nov 16, 2024

I guess that's fine with me then. I'll be merging it once you'll mark this Ready for review.

@omissis omissis force-pushed the use-schema-not-from-file branch from 97744ab to 0293bd3 Compare November 16, 2024 11:01
@ptodev ptodev marked this pull request as ready for review November 18, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants