Skip to content

Commit

Permalink
#2 fixed error in searchresult
Browse files Browse the repository at this point in the history
  • Loading branch information
David Rauh committed Feb 8, 2023
1 parent 0b79d88 commit 0bcf99a
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 57 deletions.
74 changes: 39 additions & 35 deletions api/schemas/SearchResult.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
type: array
description: A list of compounds with associated spectra.
items:
description: Data for a single compound.
type: object
properties:
metadata:
$ref: "./FilterOptions.yaml#/components/schemas/Metadata"
data:
type: object
properties:
metadata:
$ref: "./FilterOptions.yaml#/components/schemas/Metadata"
data:
type: array
description: A list of compounds with associated spectra.
items:
description: Data for a single compound.
type: object
name:
description: Compound name.
type: string
formula:
description: Formula of the compound.
type: string
mass:
description: Exact Mass of the compound.
type: number
format: double
smiles:
description: Smiles to generate structure.
type: string
spectra:
description: A list of spectra for the compound
type: array
items:
description: Spectra for the given compound
type: object
properties:
title:
description: Record title
type: string
id:
description: MassBank ID.
type: string
properties:

data:
type: object
name:
description: Compound name.
type: string
formula:
description: Formula of the compound.
type: string
mass:
description: Exact Mass of the compound.
type: number
format: double
smiles:
description: Smiles to generate structure.
type: string
spectra:
description: A list of spectra for the compound
type: array
items:
description: Spectra for the given compound
type: object
properties:
title:
description: Record title
type: string
id:
description: MassBank ID.
type: string
6 changes: 3 additions & 3 deletions cmd/mb3server/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ api/openapi.yaml
main.go
src/api.go
src/api_default.go
src/api_default_service.go
src/error.go
src/helpers.go
src/impl.go
Expand Down Expand Up @@ -35,7 +34,8 @@ src/model_mb_record_species.go
src/model_metadata.go
src/model_ms_data_processing_inner.go
src/model_ms_focused_ion_inner.go
src/model_search_result_inner.go
src/model_search_result_inner_spectra_inner.go
src/model_search_result.go
src/model_search_result_data_inner.go
src/model_search_result_data_inner_spectra_inner.go
src/model_string_count.go
src/routers.go
63 changes: 44 additions & 19 deletions cmd/mb3server/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,47 @@ components:
InChIKey:
type: string
SearchResult:
description: A list of compounds with associated spectra.
items:
$ref: '#/components/schemas/SearchResult_inner'
type: array
example:
metadata:
isomer_count: 0
git_commit: git_commit
compound_count: 0
spectra_count: 0
limit: 1
page: 1
version: version
result_count: 0
timestamp: timestamp
data:
- spectra:
- id: id
title: title
- id: id
title: title
data: "{}"
smiles: smiles
mass: 7.061401241503109
name: name
formula: formula
- spectra:
- id: id
title: title
- id: id
title: title
data: "{}"
smiles: smiles
mass: 7.061401241503109
name: name
formula: formula
properties:
metadata:
$ref: '#/components/schemas/Metadata'
data:
description: A list of compounds with associated spectra.
items:
$ref: '#/components/schemas/SearchResult_data_inner'
type: array
type: object
MBRecord:
example:
date:
Expand Down Expand Up @@ -682,7 +719,7 @@ components:
items:
$ref: '#/components/schemas/MsDataProcessing_inner'
type: array
SearchResult_inner_spectra_inner:
SearchResult_data_inner_spectra_inner:
description: Spectra for the given compound
example:
id: id
Expand All @@ -695,32 +732,20 @@ components:
description: MassBank ID.
type: string
type: object
SearchResult_inner:
SearchResult_data_inner:
description: Data for a single compound.
example:
spectra:
- id: id
title: title
- id: id
title: title
metadata:
isomer_count: 0
git_commit: git_commit
compound_count: 0
spectra_count: 0
limit: 1
page: 1
version: version
result_count: 0
timestamp: timestamp
data: "{}"
smiles: smiles
mass: 7.061401241503109
name: name
formula: formula
properties:
metadata:
$ref: '#/components/schemas/Metadata'
data:
type: object
name:
Expand All @@ -739,7 +764,7 @@ components:
spectra:
description: A list of spectra for the compound
items:
$ref: '#/components/schemas/SearchResult_inner_spectra_inner'
$ref: '#/components/schemas/SearchResult_data_inner_spectra_inner'
type: array
type: object
MBRecord_deprecated:
Expand Down
42 changes: 42 additions & 0 deletions cmd/mb3server/src/model_search_result.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* MassBank3 API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* API version: 3.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/

package mb3server

type SearchResult struct {
Metadata Metadata `json:"metadata,omitempty"`

// A list of compounds with associated spectra.
Data []SearchResultDataInner `json:"data,omitempty"`
}

// AssertSearchResultRequired checks if the required fields are not zero-ed
func AssertSearchResultRequired(obj SearchResult) error {
if err := AssertMetadataRequired(obj.Metadata); err != nil {
return err
}
for _, el := range obj.Data {
if err := AssertSearchResultDataInnerRequired(el); err != nil {
return err
}
}
return nil
}

// AssertRecurseSearchResultRequired recursively checks if required fields are not zero-ed in a nested slice.
// Accepts only nested slice of SearchResult (e.g. [][]SearchResult), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseSearchResultRequired(objSlice interface{}) error {
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
aSearchResult, ok := obj.(SearchResult)
if !ok {
return ErrTypeAssertionError
}
return AssertSearchResultRequired(aSearchResult)
})
}
52 changes: 52 additions & 0 deletions cmd/mb3server/src/model_search_result_data_inner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* MassBank3 API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* API version: 3.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/

package mb3server

// SearchResultDataInner - Data for a single compound.
type SearchResultDataInner struct {
Data map[string]interface{} `json:"data,omitempty"`

// Compound name.
Name string `json:"name,omitempty"`

// Formula of the compound.
Formula string `json:"formula,omitempty"`

// Exact Mass of the compound.
Mass float64 `json:"mass,omitempty"`

// Smiles to generate structure.
Smiles string `json:"smiles,omitempty"`

// A list of spectra for the compound
Spectra []SearchResultDataInnerSpectraInner `json:"spectra,omitempty"`
}

// AssertSearchResultDataInnerRequired checks if the required fields are not zero-ed
func AssertSearchResultDataInnerRequired(obj SearchResultDataInner) error {
for _, el := range obj.Spectra {
if err := AssertSearchResultDataInnerSpectraInnerRequired(el); err != nil {
return err
}
}
return nil
}

// AssertRecurseSearchResultDataInnerRequired recursively checks if required fields are not zero-ed in a nested slice.
// Accepts only nested slice of SearchResultDataInner (e.g. [][]SearchResultDataInner), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseSearchResultDataInnerRequired(objSlice interface{}) error {
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
aSearchResultDataInner, ok := obj.(SearchResultDataInner)
if !ok {
return ErrTypeAssertionError
}
return AssertSearchResultDataInnerRequired(aSearchResultDataInner)
})
}
37 changes: 37 additions & 0 deletions cmd/mb3server/src/model_search_result_data_inner_spectra_inner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* MassBank3 API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* API version: 3.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/

package mb3server

// SearchResultDataInnerSpectraInner - Spectra for the given compound
type SearchResultDataInnerSpectraInner struct {

// Record title
Title string `json:"title,omitempty"`

// MassBank ID.
Id string `json:"id,omitempty"`
}

// AssertSearchResultDataInnerSpectraInnerRequired checks if the required fields are not zero-ed
func AssertSearchResultDataInnerSpectraInnerRequired(obj SearchResultDataInnerSpectraInner) error {
return nil
}

// AssertRecurseSearchResultDataInnerSpectraInnerRequired recursively checks if required fields are not zero-ed in a nested slice.
// Accepts only nested slice of SearchResultDataInnerSpectraInner (e.g. [][]SearchResultDataInnerSpectraInner), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseSearchResultDataInnerSpectraInnerRequired(objSlice interface{}) error {
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
aSearchResultDataInnerSpectraInner, ok := obj.(SearchResultDataInnerSpectraInner)
if !ok {
return ErrTypeAssertionError
}
return AssertSearchResultDataInnerSpectraInnerRequired(aSearchResultDataInnerSpectraInner)
})
}

0 comments on commit 0bcf99a

Please sign in to comment.