Skip to content

Commit 3cb1695

Browse files
committed
refactor: renamings for clarity
Signed-off-by: András Jáky <[email protected]>
1 parent e7cafde commit 3cb1695

File tree

3 files changed

+128
-112
lines changed

3 files changed

+128
-112
lines changed

USAGE.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,19 @@ import (
189189
)
190190

191191
func main() {
192-
// Create a new schema instance with schema URL
192+
// Create a new schema instance with schema URL (cache disabled by default)
193193
s, err := schema.New("https://schema.oasf.outshift.com")
194194
if err != nil {
195195
log.Fatalf("Failed to create schema instance: %v", err)
196196
}
197197

198+
// Optional: enable dynamic cache (only requested data is cached)
199+
cachedClient, err := schema.New("https://schema.oasf.outshift.com", schema.WithCache(true))
200+
if err != nil {
201+
log.Fatalf("Failed to create cached schema instance: %v", err)
202+
}
203+
_ = cachedClient
204+
198205
ctx := context.Background()
199206

200207
// Get available schema versions from the server
@@ -205,23 +212,19 @@ func main() {
205212
fmt.Printf("Available schema versions: %v\n", versions)
206213

207214
// Get the default schema version (cached after first fetch)
208-
defaultVersion, err := s.GetDefaultVersion(ctx)
215+
defaultVersion, err := s.GetDefaultSchemaVersion(ctx)
209216
if err != nil {
210217
log.Fatalf("Failed to get default version: %v", err)
211218
}
212219
fmt.Printf("Default schema version: %s\n", defaultVersion)
213220

214-
// Get full schema content for version 0.8.0 (using WithVersion option)
215-
schemaContent, err := s.GetRecordSchemaContent(ctx, schema.WithVersion("0.8.0"))
221+
// Get full schema content for version 0.8.0 (using WithSchemaVersion option)
222+
schemaContent, err := s.GetRecordJSONSchema(ctx, schema.WithSchemaVersion("0.8.0"))
216223
if err != nil {
217224
log.Fatalf("Failed to get schema content: %v", err)
218225
}
219226

220-
var schemaMap map[string]interface{}
221-
if err := json.Unmarshal(schemaContent, &schemaMap); err != nil {
222-
log.Fatalf("Failed to parse schema: %v", err)
223-
}
224-
fmt.Printf("Schema version 0.8.0 loaded successfully\n")
227+
fmt.Printf("Schema version 0.8.0 loaded successfully (%d bytes)\n", len(schemaContent))
225228

226229
// Get nested skill categories (using default version - no option needed)
227230
skillsData, err := s.GetSchemaSkills(ctx)
@@ -231,7 +234,7 @@ func main() {
231234
fmt.Printf("Found %d top-level skill categories\n", len(skillsData))
232235

233236
// Get nested domain categories (using specific version)
234-
domainsData, err := s.GetSchemaDomains(ctx, schema.WithVersion("0.8.0"))
237+
domainsData, err := s.GetSchemaDomains(ctx, schema.WithSchemaVersion("0.8.0"))
235238
if err != nil {
236239
log.Fatalf("Failed to get domains: %v", err)
237240
}
@@ -269,24 +272,30 @@ if err != nil {
269272

270273
## API Methods
271274

272-
### GetDefaultVersion
275+
### GetDefaultSchemaVersion
273276
Returns the default schema version from the server. The version is cached after the first fetch:
274277
```go
275-
defaultVersion, err := s.GetDefaultVersion(ctx)
278+
defaultVersion, err := s.GetDefaultSchemaVersion(ctx)
276279
```
277280

278-
### GetRecordSchemaContent
279-
Fetches the complete JSON schema. If no version is provided via `WithVersion()`, the default version from the server is used:
281+
### Cache behavior
282+
- Caching is disabled by default.
283+
- Enable dynamic caching via constructor option: `schema.New(url, schema.WithCache(true))`.
284+
- Dynamic caching stores only data that has been requested.
285+
- Clear in-memory cache with `s.ClearCache()`.
286+
287+
### GetRecordJSONSchema
288+
Fetches the complete JSON schema. If no version is provided via `WithSchemaVersion()`, the default version from the server is used:
280289
```go
281290
// Using default version
282-
schemaContent, err := s.GetRecordSchemaContent(ctx)
291+
schemaContent, err := s.GetRecordJSONSchema(ctx)
283292

284293
// Using specific version
285-
schemaContent, err := s.GetRecordSchemaContent(ctx, schema.WithVersion("0.8.0"))
294+
schemaContent, err := s.GetRecordJSONSchema(ctx, schema.WithSchemaVersion("0.8.0"))
286295
```
287296

288297
### Convenience Methods
289-
All convenience methods accept optional `WithVersion()` option. If omitted, the default version is used. These methods call the new taxonomy endpoints and return nested Go structs (`schema.SchemaCategories`):
298+
All convenience methods accept optional `WithSchemaVersion()` option. If omitted, the default version is used. These methods call the new taxonomy endpoints and return nested Go structs (`schema.Taxonomy`):
290299
- `GetSchemaSkills(ctx, ...SchemaOption)` - calls `/api/<version>/skill_categories`
291300
- `GetSchemaDomains(ctx, ...SchemaOption)` - calls `/api/<version>/domain_categories`
292301
- `GetSchemaModules(ctx, ...SchemaOption)` - calls `/api/<version>/module_categories`
@@ -297,7 +306,7 @@ Example:
297306
skills, err := s.GetSchemaSkills(ctx)
298307

299308
// Using specific version
300-
skills, err := s.GetSchemaSkills(ctx, schema.WithVersion("0.7.0"))
309+
skills, err := s.GetSchemaSkills(ctx, schema.WithSchemaVersion("0.7.0"))
301310
```
302311

303312
# Validation Service

0 commit comments

Comments
 (0)